Python web crawler Error "Unicodedecodeerror: ' Utf-8 ' codec can ' t decode byte 0x8b in position" solution

Source: Internet
Author: User
Tags python web crawler

python3.x Crawler,

Found the error "Unicodedecodeerror: ' Utf-8 ' codec can ' t decode byte 0x8b in position 1:invalid start byte", has been looking for file errors, finally after the user's tips, the cause of the error Then there is a message in my header:

"' accept-encoding ': ' gzip, deflate '"

This is the one I copied directly from Fiddler, why the browser can be normal browsing, and Python imitation can not?

Comprehensive Online Explanation:

This sentence means that the local receive compression format data, the server passed the compressed format gzip file, and unzip this gzip file can only use deflate algorithm, the browser can be automatically extracted, the program can not automatically unzip gzip, need to set up the additional to the line, set method reference https:// www.crifan.com/set_accept_encoding_header_to_gzip_deflate_return_messy_code/

Summary: Write the crawler time still do not write ' accept-encoding ': ' gzip, deflate ', let the server pass the original file come over it, do not compress.

Python web crawler Error "Unicodedecodeerror: ' Utf-8 ' codec can ' t decode byte 0x8b in position" solution

Related Article

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.