您好,欢迎访问一九零五行业门户网

求php远程抓取代码

http://www.taodaxiang.com/credit/index/init
这个页面需要post查询后。在抓取查询的数据。这个用php怎么写?求代码
回复讨论(解决方案) 建议你参考一下curl
百度一下有很多
不行。百度的都抓取失败。
没有人吗?
curl 就可以,不过查询到的信息是通过 app_init.js 动态写入页面的
所以你还需抓取 app_init.js 后自行解析
比如取回的页面中有
注册时间:
实名认证:

app_init.js 中有 $(#info_regtime).html(+data.regtime+);$(#info_auth).html(+data.auth+);
curl 这个好像不用你说哟。php抓取三种方式,我都试过了。就是抓取失败。所以才来发帖求助
js?入dom的,需要curl後再分析,再curl?取的。
我试了下只能抓取到一个空页面(就一个[] 内容),应该是做了只能本站点提交表单的限制
authentication = 0; if($use == true) $this->authentication = 1; } public function setname($name){ $this->auth_name = $name; } public function setpass($pass){ $this->auth_pass = $pass; } public function __construct($url,$followlocation = true,$timeout = 30,$maxredirecs = 4,$binarytransfer = false,$includeheader = false,$nobody = false) { $this->_url = $url; $this->_followlocation = $followlocation; $this->_timeout = $timeout; $this->_maxredirects = $maxredirecs; $this->_nobody = $nobody; $this->_includeheader = $includeheader; $this->_binarytransfer = $binarytransfer; $this->_cookiefilelocation = dirname(__file__).'/cookie.txt'; } public function setreferer($referer){ $this->_referer = $referer; } public function setcookifilelocation($path) { $this->_cookiefilelocation = $path; } public function setpost ($postfields) { $this->_post = true; $this->_postfields = $postfields; } public function setuseragent($useragent) { $this->_useragent = $useragent; } public function createcurl($url = 'nul') { if($url != 'nul'){ $this->_url = $url; } $s = curl_init(); curl_setopt($s,curlopt_url,$this->_url); curl_setopt($s,curlopt_httpheader,array('expect:')); curl_setopt($s,curlopt_timeout,$this->_timeout); curl_setopt($s,curlopt_maxredirs,$this->_maxredirects); curl_setopt($s,curlopt_returntransfer,true); curl_setopt($s,curlopt_followlocation,$this->_followlocation); curl_setopt($s,curlopt_cookiejar,$this->_cookiefilelocation); curl_setopt($s,curlopt_cookiefile,$this->_cookiefilelocation); if($this->authentication == 1){ curl_setopt($s, curlopt_userpwd, $this->auth_name.':'.$this->auth_pass); } if($this->_post) { curl_setopt($s,curlopt_post,true); curl_setopt($s,curlopt_postfields,$this->_postfields); } if($this->_includeheader) { curl_setopt($s,curlopt_header,true); } if($this->_nobody) { curl_setopt($s,curlopt_nobody,true); } /* if($this->_binary) { curl_setopt($s,curlopt_binarytransfer,true); } */ curl_setopt($s,curlopt_useragent,$this->_useragent); curl_setopt($s,curlopt_referer,$this->_referer); $this->_webpage = curl_exec($s); $this->_status = curl_getinfo($s,curlinfo_http_code); curl_close($s); } public function gethttpstatus() { return $this->_status; } public function __tostring(){ return $this->_webpage; }}$m=new mycurl(http://www.taodaxiang.com/credit/index/get);$m->setreferer(http://www.taodaxiang.com/credit/index/init);$m->setpost(array(account=>cupjava));$m->createcurl();echo $m;?>
json结果出来解析一下就好了
9楼是神人。万分感谢,可以了
其它类似信息

推荐信息