爬虫之UnicodeEncodeError: 'latin-1' codec

今天在爬虫的时候碰到了这样的问题,应该是头文件里面出现了汉字,
由于不懂具体原因,我就把它删去了,如果有小伙伴懂的话,请告诉我一下。

UnicodeEncodeError: 'latin-1' codec can't encode characters in 
position 0-6: ordinal not in range(256)

对应的头文件如下:

headers = {
    "Accept": "application/json, text/javascript, */*; q=0.01",
    "Accept-Encoding": "gzip, deflate, sdch",
    "Accept-Language": "zh-CN,zh;q=0.8",
    "Connection": "keep-alive",
    # "Cookie": "需要终身会员的cookie,终身会员39元,每天可以下载30套",
    "Host": "www.500d.me",
    "Referer": "http://www.500d.me/template/491.html",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
    "X-Requested-With": "XMLHttpRequest"
}

可以看到cookie那一行为汉字,注释了之后便不报错了,至于注释后有没有影响,还请朋友们告知一下

你可能感兴趣的:(爬虫)