python 获取网页并将其保存至文本文件中

fn = 'G:\\pythonProject\\result.txt'
import requests

url = 'http://www.163.com'
string = requests.get(url)



with open(fn,'w') as file_obj:
    file_obj.write(string.text.encode('gbk', 'ignore').decode('gbk'))
    原文作者:jidawanghao
    原文地址: https://blog.csdn.net/jidawanghao/article/details/108148868
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞