Python取页面源代码
取页面源代码
点击查看代码
#打开一个网址
from urllib.request import urlopen
url="http://www.baidu.com"
res=urlopen(url)
# print(res.read().decode("utf-8"))#拿到的是网页源代码
#
with open("mybaidu.htm",mode="w",encoding="utf-8")as f:
f.write(res.read().decode("utf-8"))
本文来自博客园,作者:Awindow,转载请注明原文链接:https://www.cnblogs.com/lixinsi/p/15508051.html