Problems with the Post crawl page

Source: Internet
Author: User

A classmate reflects, spider through post way crawl a site has a problem, always 302 to oneself, specific as follows:

Url:http://www.meituan.com/multiact/default/deal/25814805.html

Post data: "Yui_3_16_0_1_1423700000_000:{\" act\ ": \" deal/dynamiccomponent\ ", \" Args\ ": 25814805,\" __referer\ ": \" \ "}"

With Python, you can crawl the code as follows:

Import Urllibimport urllib2values = {        ' yui_3_16_0_1_1423700000_000 ': ' {' act ': ' deal/dynamiccomponent ', ' args ' : 25814805, "__referer": ""} ',}header={        "X-requested-with": "XMLHttpRequest",}url= "http://www.meituan.com/ multiact/default/deal/25814805.html "data = Urllib.urlencode (values) Print Datareq = Urllib2. Request (URL, data,header) response = Urllib2.urlopen (req) the_page = Response.read () print The_page

However, the configuration of the HTTP request packet cannot be crawled, the request packet is as follows:
Post/multiact/default/deal/25814805.html http/1.1^m
Host:www.meituan.com^m
Content-length:126^m
Connection:close^m
Content-type:application/x-www-form-urlencoded^m
user-agent:mozilla/5.0 (Windows NT 5.1; rv:6.0.2) gecko/20100101 firefox/6.0.2^m
Accept-encoding:gzip^m
Accept: */*^m
X-requested-with:xmlhttprequest^m


Crawl failure reason, missing this parameter: content-type:application/x-www-form-urlencoded^m

Plus on it, specifically as follows:

Post/multiact/default/deal/25814805.html http/1.1^m
Host:www.meituan.com^m
Content-length:126^m
Connection:close^m
Content-type:application/x-www-form-urlencoded^m
user-agent:mozilla/5.0 (Windows NT 5.1; rv:6.0.2) gecko/20100101 firefox/6.0.2^m
Accept-encoding:gzip^m
Accept: */*^m
X-requested-with:xmlhttprequest^m

Content-type:application/x-www-form-urlencoded^m

Problems with the Post crawl page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.