问题描述
- 【400C币】求php远程抓取的代码!
-
网址是 http://www.taodake.com获取远程post查询后,抓取查询的数据。求教代码,帮帮忙400C币酬谢了;
已经有人找到接口了,只能是普通的旺旺号,换成商城旺旺或C店旺旺就查询不到了,估计是另一个接口,请求大家帮找一下另一个接口;
解决方案
function escape($string, $in_encoding = 'UTF-8',$out_encoding = 'UCS-2') {
$return = '';
if (function_exists('mb_get_info')) {
for($x = 0; $x < mb_strlen ( $string, $in_encoding ); $x ++) {
$str = mb_substr ( $string, $x, 1, $in_encoding );
if (strlen ( $str ) > 1) { // 多字节字符
$return .= '%u' . strtoupper ( bin2hex ( mb_convert_encoding ( $str, $out_encoding, $in_encoding ) ) );
} else {
$return .=$str;// '%' . strtoupper ( bin2hex ( $str ) );
}
}
}
return $return;
}
$nick=escape('top百分百');
$taobaourl='http://wwwsoso002.taodake.com/taobao_data.php?callback=&nick=' .$nick .'&chkid=0&click=373635346667686A63786365&_=1422435566660';
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, 'http://www.taodake.com/');
curl_setopt($ch, CURLOPT_COOKIE, 'Hm_lvt_ebeb4888fc38c5c3a030f255b55395e3=1422448628; Hm_lpvt_ebeb4888fc38c5c3a030f255b55395e3=1422448800');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36');
curl_setopt($ch, CURLOPT_URL, $taobaourl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$content=trim($content,'()');//去除首尾的括号,回调函数没传,所以不用理会了
$data = json_decode($content, true);
echo $data['b'];
这个是php版本的。。
解决方案二:
是同一个接口的。。中文内容要编码一下才行,
PHP实现javascript的escape和unescape函数:http://www.jb51.net/article/39249.htm
<b>HTML</b>
<div id="dv"></div>
<br /><br /><br /><b>评价</b>
<div id="dvRemark"></div>
<script>
function getResult(data) {
document.getElementById('dv').innerHTML = data.b
}
function getRemark(data) {
document.getElementById('dvRemark').innerHTML = data.b
}
</script>
<script>
var nick = 'top百分百';
nick = escape(nick);
document.write('<script src="http://wwwsoso002.taodake.com/taobao_data.php?callback=getResult&nick=' + nick + '&chkid=0&click=373635346667686A63786365&_=1422435566660"></script>');
document.write('<script src="http://wwwsoso002.taodake.com/givetraderate.php?callback=getRemark&nick=' + nick + '&click=373635346667686A63786365&_=1422435566863"></script>');
</script>
解决方案三:
大哥,能加我一下QQ吗?C币是我冲值的,我宁可给你钱,这样问你更方便,我QQ80206391
解决方案四:
接口视乎被加密了,抓取不过来内容。这杂回事?
时间: 2025-01-26 23:56:04