爬虫1-爬虫入门
?爬蟲 通過編寫程序來獲取到互聯(lián)網(wǎng)上的資源
?需求:用程序模擬瀏覽器 輸入一個(gè)網(wǎng)址 從該網(wǎng)址中獲取到資源或者內(nèi)容?
"""
File: 01入門.py
Author: chde_wang
Date: 2021-04-19 14:30:31
Description:
"""
# 爬蟲 通過編寫程序來獲取到互聯(lián)網(wǎng)上的資源
# 百度
# 需求:用程序模擬瀏覽器 輸入一個(gè)網(wǎng)址 從該網(wǎng)址中獲取到資源或者內(nèi)容
from urllib.request import urlopen
url = "http://www.baidu.com"
resp = urlopen(url)print(resp)
print(resp.read().decode("utf-8"))with open("mybaidu.html",mode="w") as f:f.write(resp.read().decode("utf-8"))
print("over!")
?
總結(jié)
- 上一篇: VS2015+cmake3.8+open
- 下一篇: 我的模型--