在POST请求中请求有效负载

时间:2013-03-22 00:47:15

标签: php post request screen-scraping payload

我正在尝试抓取一个PHP网站,而不是表单数据,我在Header部分看到Payload请求。什么是有效负载请求?我正在使用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请求?任何帮助将不胜感激。

0 个答案:

没有答案