我的第一个爬虫,爬取百度首页的页面源代码。
from urllib.request import urlopen
url = "http://www.baidu.com"
resp = urlopen(url)
with open("mybaidu.html", "w", encoding="utf-8") as f:
f.write(resp.read().decode("utf-8")) #读取网页的页面源代码
print("over!")
我的第一个爬虫,爬取百度首页的页面源代码。
from urllib.request import urlopen
url = "http://www.baidu.com"
resp = urlopen(url)
with open("mybaidu.html", "w", encoding="utf-8") as f:
f.write(resp.read().decode("utf-8")) #读取网页的页面源代码
print("over!")