1

我正在尝试抓取一个 PHP 网站,而不是表单数据,我在标题部分看到有效负载请求。什么是有效载荷请求?我正在使用 Chrome 的开发人员工具来分析数据。

例如:

Request Payload
------WebKitFormBoundaryWEXJCV0v7CwVqn0X
Content-Disposition: form-data; name="Command"

-1
------WebKitFormBoundaryWEXJCV0v7CwVqn0X
Content-Disposition: form-data; name="name_1"

12
------WebKitFormBoundaryWEXJCV0v7CwVqn0X
Content-Disposition: form-data; name="pass_1"

34
------WebKitFormBoundaryWEXJCV0v7CwVqn0X
Content-Disposition: form-data; name="logins"

Είσοδος
------WebKitFormBoundaryWEXJCV0v7CwVqn0X
Content-Disposition: form-data; name="email"

我想做的就是抓取一个需要用户名和密码的网站。

My code is this:
function get_data_with_post_fields($url, $fields_data) {

      $ch = curl_init();
      $timeout = 5;
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt($ch, CURLOPT_ENCODING, ""); 
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_data);
      curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);

      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
}






$url_to_scrape = 'http://www.awebsite.com/index.php?com=products&id=10000';




                $PF = "&name_1=xxx&pass_1=xxx";



        print $raw = get_data_with_post_fields($url_to_scrape,$PF);

我应该如何形成我的 POST REQUEST?任何帮助都感激不尽。

4

0 回答 0