全新的程式員。
試圖用下面的類來抓取特定的方面。檢查視窗中共有 5 個。當我嘗試列印第三個索引時,它給了我一個“超出范圍”的錯誤。關于為什么的任何線索?
import bs4
from bs4 import BeautifulSoup
import requests
import lxml
vegas_insider = requests.get('https://www.vegasinsider.com/college-football/matchups/', 'r').text
soup = BeautifulSoup(vegas_insider, 'lxml')
closing_line = soup.find('td', class_ = 'viCellBg2 cellBorderL1 cellTextNorm padCenter').text[2]
print(float(closing_line))
uj5u.com熱心網友回復:
find()只回傳一個元素,它找到的第一個元素。如果您希望所有元素都帶有特定標簽,則必須find_all()改用。
https://beautiful-soup-4.readthedocs.io/en/latest/index.html?highlight=find#find
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/320994.html
