How to solve 403 error returned by Python crawler

Source: Internet
Author: User
This indicates that the website uses anti-crawling technology anti-web-crawlingtechnique (used by Amazon). it is relatively simple to check the user agent information.

Problem

When capturing data, the common debugging information is:

DEBUG: Crawled (200) 
 
   (referer: None)
 

If

DEBUG: Crawled (403) 
 
   (referer: None)
 

This indicates that the website uses anti-crawling technology anti-web-crawler technique (used by Amazon), which is easy to check the User Agent information.

Solution

Construct a User Agent in the request header as follows:

def start_requests(self):      yield Request("#",                    headers={'User-Agent': "your agent string"})

The above is the details about how the Python crawler returns the 403 error solution. For more information, see other related articles in the first PHP community!

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.