Request PHP Remote Fetch code

Source: Internet
Author: User
Http://www.taodaxiang.com/credit/index/init

This page requires post query. The data in the fetch query. How do you write this in PHP? Request Code


Reply to discussion (solution)

I suggest you refer to curl
Baidu a little bit more

No way. Baidu's crawl failed.

No one?

Curl is available, but the information that is queried is dynamically written to the page by App_init.js
So you need to crawl app_init.js and parse it yourself.

For example, the retrieved page has

Registration time:

Real name Certification:

There are app_init.js in the
$ ("#info_regtime"). HTML ("+data.regtime+"); $ ("#info_auth"). HTML ("+data.auth+");

Curl doesn't seem like you need to say it. PHP Crawl three ways, I have tried. is the crawl failure. That's why I'm posting for help.

JS into the DOM, you need curl to analyze, and then curl to take.

I try to crawl only to an empty page (on a [] content), should be done only this site to submit the form restrictions

 authentication = 0;     if ($use = = true) $this->authentication = 1;     The Public Function SetName ($name) {$this->auth_name = $name;     The Public Function SetPass ($pass) {$this->auth_pass = $pass; The Public function __construct ($url, $followlocation = True, $timeOut = $, $maxRedirecs = 4, $binaryTransfer = False, $incl         Udeheader = 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 ';     The Public Function Setreferer ($referer) {$this->_referer = $referer;     The Public Function setcookifilelocation ($path) {$this->_cookiefilelocation = $path; } Public Function setPost ($postFields) {$this->_post = true;     $this->_postfields = $postFields;     The Public Function setuseragent ($userAgent) {$this->_useragent = $userAgent;        The 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 results come out and parse it out.

The 9 floor is a man of God. Thank you so much.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.