我想通过这个代码刮,但我只得到了页面中的前10个货币,但页面包含100个货币,其他90个在哪里
from bs4 import BeautifulSoup as S
import requests
url = 'https://coinmarketcap.com/'
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}
r = requests.get(url,headers=headers)
soup = S(r.content,'html.parser')
price = soup.find_all('td')
for coin in soup.find_all(class_="sc-1teo54s-2 fZIJcI"):
print(coin) ```
尝试以下操作以获得100个结果
输出如下(截断):
向下滚动时,CoinMarketCap网站将加载数据。这意味着,如果你想抓取所有显示的加密货币数据,你需要先向下滚动到页面底部
BeautifulSoup不允许您向下滚动页面,因此您需要使用类似Selenium的Web驱动程序
相关问题 更多 >
编程相关推荐