小编Lau*_*ent的帖子

用 BeautifulSoup 刮硬币市场

我想抓取此页面中包含的所有数据。不幸的是,我只能提取前三行。

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)

感谢您的帮助

python beautifulsoup web-scraping

1
推荐指数
1
解决办法
482
查看次数

标签 统计

beautifulsoup ×1

python ×1

web-scraping ×1