PHP Curl Crawl Ajax asynchronous content, curlajax_php tutorial

Source: Internet
Author: User

PHP Curl crawls Ajax asynchronous content, Curlajax


In fact, grab Ajax asynchronous content of the page and catch the ordinary page is not very different. Ajax simply makes an asynchronous HTTP request, as long as it uses firebug-like tools to find the requested backend service URL and value-passing parameters, and then fetches the URL parameters.

Using Firebug's Network Tools

Code

$cookie _file=Tempnam('./temp ', ' Cookie ');$ch=curl_init ();$url 1= "Http://www.cdut.edu.cn/default.html"; curl_setopt ($ch, Curlopt_url,$url 1); curl_setopt ($ch, Curlopt_http_version,curl_http_version_1_1); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, curlopt_returntransfer,1); curl_setopt ($ch, curlopt_followlocation,1); curl_setopt ($ch, curlopt_encoding, ' gzip ');//Add gzip parse//Set file to save cookie information after connection endscurl_setopt ($ch, Curlopt_cookiejar,$cookie _file);$content=curl_exec ($ch); Curl_close ($ch);$ch 3=curl_init ();$url 3= "Http://www.cdut.edu.cn/xww/dwr/call/plaincall/portalAjax.getNewsXml.dwr";$curlPost= "callcount=1&page=/xww/type/1000020118.html&httpsessionid=12a9b726e6a2d4d3b09de7952b2f282c& Scriptsessionid=295315b4b4141b09da888d3a3adb8faa658&c0-scriptname=portalajax&c0-methodname=getnewsxml &c0-id=0&c0-param0=string:10000201&c0-param1=string:1000020118&c0-param2=string:news_& C0-param3=number:5969&c0-param4=number:1&c0-param5=null:null&c0-param6=null:null&batchid=0 "; curl_setopt ($ch 3, Curlopt_url,$url 3); curl_setopt ($ch 3, curlopt_post,1); curl_setopt ($ch 3, Curlopt_postfields,$curlPost);//set up files to save cookie information after connection endscurl_setopt ($ch 3, Curlopt_cookiefile,$cookie _file); $content 1=curl_exec ($ch 3); Curl_close ($ch 3);

I'm the dividing line of the king of the Land Tiger.


PHP Curl does not respond after fetching AJAX data for some time

Attempt to forge header information: Host, Referer, user-agent, etc.

PHP uses curl to crawl the content of a site is rejected

It's just written. Hope Useful
>

http://www.bkjia.com/PHPjc/868765.html www.bkjia.com true http://www.bkjia.com/PHPjc/868765.html techarticle PHP Curl Crawl Ajax asynchronous content, Curlajax actually grab Ajax asynchronous content of the page and catch the ordinary page is not very different. Ajax just made an asynchronous HTTP request, just use Fireb ...

  • 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.