php登录后废弃网站

时间:2016-09-08 05:36:01

标签: php curl web-scraping

我想在登录后删除某个网站,但无法这样做,我的Chrome开发人员工具会给我以下数据来制作卷曲

Request URL:http://example.com/ab/index.php/company
Request Method:POST
Status Code:302 Found
Remote Address:x.x.x.x:80

Request Headers
 Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:120
Content-Type:application/x-www-form-urlencoded
Cookie:PHPSESSID=d2mnsm293nhadmmtoananmaa; abc_fd_test=3fdb2f2be5acda39ae4aa7679f224466
Host:example.com
Origin:http://example.com
Referer:http://example.com/ab/
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/x.x.x.x Safari/537.36

Form Data

abc_fd_test:3fdb2f2be5acda39ae4aa7679f224466
email:abc@abc.com
password:xxxxxx
btnLogin:Sign in

我的curl代码在

之下
 <?php
 $url="http://example.com/ab/index.php/company";

 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
 curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
 curl_setopt($ch, CURLOPT_HEADER, 1);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('email' =>   'abc@abc.com', 'password' => 'xxxxxx')));
 curl_setopt($ch, CURLOPT_REFERER, "http://example.com/ab/");
 curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
 $data = curl_exec($ch);
 var_dump($data);

?> 

有一点我注意到上面的代码正在发出GET请求而不是POST。如果需要添加任何内容,请提供帮助。表单还发布了一个隐藏字段abc_fd_test,每次表单加载时都会更改。

0 个答案:

没有答案