如何模拟CURLOPT_FOLLOWLOCATION
?此功能在我的网络服务器上禁用。CURLOPT_FOLLOWLOCATION仿真
我想从网站的统计数据,但我无法得到正确的页面。
请求:
POST https://www.example.com/login HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22 Content-Length: 200 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Origin: https://www.example.com Content-Type: application/x-www-form-urlencoded Referer: https://www.example.com/login?logout=1&final_logout=1& Accept-Language: ru-RU Accept-Encoding: gzip, deflate Cookie: mochipass_session= Connection: keep-alive Proxy-Connection: keep-alive t_token=%3A1320923163%3A191098013553085002228331177770025958552%3AvcXtA5YwNT58Nt6uEGK-gvwpGqM%21&email=mytesingcomp&password=mytesingcomp&remember_me=on&login=Login&service=ads&host=www.mochimedia.com
答:
HTTP/1.1 302 Moved Temporarily Date: Thu, 10 Nov 2011 11:06:40 GMT Connection: close Set-Cookie: example_session=mytesingcomp&1320923200&H3rV7aMe&euqh6CL4I7x2PgtWcsJa-X0n_r4!; Version=1; Expires=Thu, 24-Nov-2011 11:06:40 GMT; Max-Age=1209600; Secure Server: Example/1.0 (Any of you quaids got a smint?) Location: https://www.example.com/login?email=mytesingcomp%40mail.ru&alias=mytesingcomp&status=verified®istered_service=ads×tamp=1320923200&nonce=hmCFzV-9&hmac=EHNUJYf2dbVsg8Y-J7iEdzgHyT0%21&login=login Content-Length: 46 X-Example-Server: 38.102.129.29:443 P3P: policyref="http://www.example.com/p3p/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV" X-Example-Backend: 10.0.0.107:40061 X-Example-Source: 10.0.0.237:44200 CONGRATULATIONS, you're logged in. Redirecting
现在我们需要做的重定向,如何与卷曲做到吗?
是不是你的问题自答?使用curl_setopt($ handle,CURLOPT_FOLLOWLOCATION,true); – dmitry
不,我不能使用CURLOPT_FOLLOWLOCATION,我需要模拟它。 –
因此,如果HTTP代码是30x,请阅读标题“位置”,按照您的要求进行操作并手动转到该位置 – dmitry