1
リンクでは、r_compare_bars_value
クラスのspanタグからテキストを取得したいとします。そのクラスを検索すると、104 (min: 88) fps
というテキストが表示され、min:88
部分のみを取得したかったのです。私のコード;スパンタグからテキストを取得する
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
を試して、スパンタグなしで試しました。そのウェブサイトのコードは本当に混乱しています。私のミスはどこにありますか?これをどのように修正できますか?