我想抓取此页面中包含的所有数据。不幸的是,我只能提取前三行。
import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.coingecko.com/fr/pièces/bitcoin#markets")
soup = BeautifulSoup(response.text, "html.parser")
My_table = soup.find("table",{"class":"table table-scrollable"})
My_table
data = []
rows = My_table.find_all('tr')
for row in rows:
cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols]
data.append([ele for ele in cols if ele]) # Get rid of empty values
data
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助