爬虫问题汇总

request / BeautifulSoup 解析 ISO - 8859 - 1 / GB2312 页面乱码错误

设置 r.encoding = ‘GB2312’

# r.encoding = 'GB2312'

r = requests.get(i,)
    print(r.encoding)
    # ISO - 8859 - 1
    r.encoding = 'GB2312'

print (r.text) :
# 国物权法》(上册),张双根译,法律出版社2004
#  style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-#family:
#  "Times New Roman"'>年版,第187
#  style='font-family:宋体;mso-ascii

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