1
在鏈接中,我想從r_compare_bars_value
類的span標籤中獲取文本。如果您搜索該課程,您會看到文字爲104 (min: 88) fps
,我只想要採取min:88
部分。我的代碼;從span標籤中獲取文本問題
from bs4 import BeautifulSoup
import urllib.request,requests
r = urllib.request.urlopen('http://www.notebookcheck.net/Computer-Games-on-Laptop-Graphics-Cards.13849.0.html').read()
soup = BeautifulSoup(r)
links = [a['href'] for a in soup.select(".gpugames_header_games > a")]
for url in links:
if url != "":
print (url)
rr = requests.get(url).content
soup = BeautifulSoup(rr,"html.parser")
for aa in soup.select("div.r_compare_bars_value span"):
print (aa)
if "min:" in aa.text:
print (aa.text)
但是它現在沒有打印任何其他類別的大量字符串打印,而不是min:88
部分。我也試過div.tx-nbc2fe-pi1
,並嘗試沒有span標籤。該網站的代碼真的很糟糕。我的錯誤在哪裏,我該如何解決這個問題?