我是網路抓取的新手,我試圖從以下網頁中僅提取 100 個有趣的事實:

編碼:
from urllib.request import urlopen
from bs4 import BeautifulSoup
url = "https://holypython.com/100-python-tips-tricks/"
html = urlopen(url).read()
soup = BeautifulSoup(html, features="html.parser")
titles = soup.select("h3[class='elementor-heading-title elementor-size-default']")
for title in titles:
print(title.text)
我將把它作為練習留給你,你可以根據需要格式化資料。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/519407.html
