生成的网页打卡乱码,但是url若换成www.baidu.com则正常,查看后发现贴吧编码是gbk,百度首页编码是gb2312。不知道是什么原因?
# -*- coding:utf-8 -*-
from pyquery import PyQuery as pq
import codecs
d = pq(url'http://tieba.baidu.com/f?kw=宋时行')
sep = d('body').html()
file = codecs.open('new.html', 'w', 'utf-8')
file.write(sep)
file.close()
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师