首先安裝 python3 環(huán)境(詳細(xì)的安裝方法,百度上很多)
在E盤(pán)新建 python3-webcrawler 目錄(后面所有爬蟲(chóng)文件均放在該目錄中)
新建 1.py 文件,將以下代碼拷貝到文件中
from urllib.request import urlopen
html = urlopen("http://www.toutiao.com/")
print(html.read())
- 按住 shift 建,鼠標(biāo)右鍵點(diǎn)擊 python3-webcrawler, 然后點(diǎn)擊“在此處打開(kāi)命令窗口”
-
運(yùn)行命令 python 1.py , 可以看到爬取到的結(jié)果,如下圖
python3網(wǎng)絡(luò)爬蟲(chóng) (1)-最簡(jiǎn)單的請(qǐng)求網(wǎng)頁(yè)