BeautifulSoup 常用的網頁解析器
# BeautifulSoup 常用的網頁解析器 BeautifulSoup(html, "html.parser") # → 速度中等,容錯率強,python內建資料庫 BeautifulSoup(html, "lxml") # → 速度快,但須裝C語言套件 BeautifulSoup(html, "xml") # → 速度快,但須裝C語言套件 BeautifulSoup(html, "html5lib") # → 速度慢,容錯率最強,不須安裝額外套件 # 常見 error BeautifulSoup: object of type 'Response' has no len() # 解決方法如下: res = requests.get(url).content
import requests
回覆刪除from bs4 import BeautifulSoup
res = requests.get("https://www.youtube.com/feed/trending")
soup = BeautifulSoup(res.text)
for ytd_video_renderer in soup.select('.ytd-video-renderer'):
print(ytd_video_renderer.select('.text-wrapper')[0].text)
print(ytd_video_renderer.select('.ytd-video-meta-block')[0].text)
這是我用youtube的模式打的,可是沒有出現錯誤訊息,也沒有輸出任何東西,想知道要怎麼解決,謝謝您幫忙XDD
Titanium White Wheels | Titanium Wheels - T-Tech
回覆刪除Titanium White titanium dioxide sunscreen Wheels. T-Tech is 2021 ford escape titanium hybrid a premium quality, micro touch hair trimmer affordable brand. We have titanium scooter bars an suppliers of metal authentic luxury brand for you.