将抓取的网页保存到本地,可以使用 Python3 File write() 方法

from urllib.request import urlopen

myURL = urlopen("https://www.runoob.com/")
f = open("runoob_urllib_test.html", "wb")
content = myURL.read()  # 读取网页内容
f.write(content)
f.close()

posted @ 2022-02-14 22:45  xjspyx  阅读(66)  评论(0编辑  收藏  举报