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