pywebcopy复制的网站是有什么解决办法吗?-灵析社区

谁能阻止我删代码

python3.9 程序如下: from pywebcopy import save_webpage save_webpage( url='http://www.hippter.com/', project_folder='D:/Python/script', project_name='my_site3', bypass_robots=True,# 调试 debug=True, open_in_browser=True,# 在浏览器中打开 delay=None,# 延迟 threaded=False,# 线程 ) 问题: 如何显示中文,不出现乱码?

阅读量:318

点赞量:15

问AI
第三方库: from bs4 import BeautifulSoup with open('path/to/your/saved/html/file.html', 'r', encoding='utf-8') as file: soup = BeautifulSoup(file, 'html.parser') if soup.meta: soup.meta['charset'] = 'utf-8' else: soup.head.append(soup.new_tag('meta', charset='utf-8')) with open('path/to/your/saved/html/file.html', 'w', encoding='utf-8') as file: file.write(str(soup))