~~~
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')