Python 第一支爬蟲(Jupyter Notebook)
試用 Pythone 試作爬蟲。使用 Jupyter Notebook。
引言
參考
開發環境
安裝相關套件
啟動 Jupyter Notebook
Python 指令紀錄
沒圖沒真象

Last updated
試用 Pythone 試作爬蟲。使用 Jupyter Notebook。

Last updated
> pip install jupyter notebook> pip install requests> pip install beautifulsoup4> jupyter notebookimport requests
from bs4 import BeautifulSoup
r = requests.get("https://www.ptt.cc/bbs/MobileComm/index.html")
print(r.text)import requests
from bs4 import BeautifulSoup
soup = BeautifulSoup(r.text,"html.parser") #將網頁資料以html.parser
sel = soup.select("div.title a") #取HTML標中的 <div class="title"></div> 中的<a>標籤存入sel
for s in sel:
print(s["href"], s.text)