php淘宝评论采集
2015-10-21 08:38
441 查看
前段时间一个朋友需要些一个采集淘宝评论的代码来为自己的cms做原创优化,存在2个问题,一个是编码,一个是采集接口。直接上我写的代码吧;
function getword(){
// 淘宝评论的js,itemId和sellerId在采用的天猫产品页面看源代码能找到,spuId不用管
$url ='https://rate.tmall.com/list_detail_rate.htm?itemId=42154201960&spuId=1714128138&sellerId=1714128138&order=1';
$res = file_get_contents($url);
// 匹配评论部分
preg_match_all("/Content\":\"((.|\n)*?)\"/",$res, $match);
$wt = array();
$arr = $match[1];
// 去除空评论
foreach ($arr as $v) {
if($v != ''){
// 转化成utf-8编码
$wt[] = iconv("GBK","UTF-8", $v);
}
}
return $wt;
}
不明白的加qq:79442126
function getword(){
// 淘宝评论的js,itemId和sellerId在采用的天猫产品页面看源代码能找到,spuId不用管
$url ='https://rate.tmall.com/list_detail_rate.htm?itemId=42154201960&spuId=1714128138&sellerId=1714128138&order=1';
$res = file_get_contents($url);
// 匹配评论部分
preg_match_all("/Content\":\"((.|\n)*?)\"/",$res, $match);
$wt = array();
$arr = $match[1];
// 去除空评论
foreach ($arr as $v) {
if($v != ''){
// 转化成utf-8编码
$wt[] = iconv("GBK","UTF-8", $v);
}
}
return $wt;
}
</pre><pre>
不明白的加qq:79442126
相关文章推荐
- PHP批量删除
- smtp时常要重启才能收发邮件
- smtp时常要重启才能收发邮件
- smtp时常要重启才能收发邮件
- smtp时常要重启才能收发邮件
- Php上传文件
- Php数据库操作
- 使用TFTP进行文件传输
- PHP中字符串转换为数值 可能会遇到的坑
- PHP实现清除wordpress里恶意代码
- PHP 实现的将图片转换为TXT
- PHP中的switch语句的用法实例详解
- PHP中使用substr()截取字符串出现中文乱码问题该怎么办
- php获取汉字拼音首字母的方法
- 使用xampp搭建运行php虚拟主机的详细步骤
- 功能强大的PHP图片处理类(水印、透明度、旋转)
- 为你总结一些php系统类函数
- 深入理解PHP变量的值类型和引用类型
- 为你总结一些php信息函数
- php精确的统计在线人数的方法