~~~
urlopen爬取百度首页HTML
~~~
````
#百度首页爬取
from urllib.request import urlopen #从请求库中导入urlopen
url = "http://www.baidu.com"
resp = urlopen(url)
with open("baidu.html", mode\="w") as f:
f.write(resp.read().decode('utf-8')) #读取到的网页的数据
f.close()
print('over')