PHP curl 抓取AJAX异步内容,curlajax
其实抓ajax异步内容的页面和抓普通的页面区别不大。ajax只不过是做了一次异步的http请求,只要使用firebug类似的工具,找到请求的后端服务url和传值的参数,然后对该url传递参数进行抓取即可。
利用Firebug的网络工具
Code
<span>$cookie_file</span>=<span>tempnam</span>('./temp','cookie'<span>); </span><span>$ch</span> =<span> curl_init(); </span><span>$url1</span> = "http://www.cdut.edu.cn/default.html"<span>; curl_setopt(</span><span>$ch</span>,CURLOPT_URL,<span>$url1</span><span>); curl_setopt(</span><span>$ch</span>,CURLOPT_HTTP_VERSION,<span>CURL_HTTP_VERSION_1_1); curl_setopt(</span><span>$ch</span>,CURLOPT_HEADER,0<span>); curl_setopt(</span><span>$ch</span>,CURLOPT_RETURNTRANSFER,1<span>); curl_setopt(</span><span>$ch</span>,CURLOPT_FOLLOWLOCATION,1<span>); curl_setopt(</span><span>$ch</span>, CURLOPT_ENCODING ,'gzip'); <span>//</span><span>加入gzip解析 //设置连接结束后保存cookie信息的文件</span> curl_setopt(<span>$ch</span>,CURLOPT_COOKIEJAR,<span>$cookie_file</span><span>); </span><span>$content</span>=curl_exec(<span>$ch</span><span>); curl_close(</span><span>$ch</span><span>); </span><span>$ch3</span> =<span> curl_init(); </span><span>$url3</span> = "http://www.cdut.edu.cn/xww/dwr/call/plaincall/portalAjax.getNewsXml.dwr"<span>; </span><span>$curlPost</span> = "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"<span>; curl_setopt(</span><span>$ch3</span>,CURLOPT_URL,<span>$url3</span><span>); curl_setopt(</span><span>$ch3</span>,CURLOPT_POST,1<span>); curl_setopt(</span><span>$ch3</span>,CURLOPT_POSTFIELDS,<span>$curlPost</span><span>); </span><span>//</span><span>设置连接结束后保存cookie信息的文件</span> curl_setopt(<span>$ch3</span>,CURLOPT_COOKIEFILE,<span>$cookie_file</span><span>); </span><span>$content1</span>=curl_exec(<span>$ch3</span><span>); curl_close(</span><span>$ch3</span>);
我是天王盖地虎的分割线
尝试伪造 头信息 :Host 、Referer、User-Agent 等
刚写的。希望有用
>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment