Web删除多个页面的WHIT计数和URL中的偏移功能

发布于 2025-02-12 03:18:45 字数 511 浏览 0 评论 0原文

我正在尝试从Yahoo未婚夫网站上进行网络刮擦股票,以获取加密货币。 但是我无法解决分页问题。 我试图以这种方式在URL中循环循环,并抵消参数:


import requests
from bs4 import BeautifulSoup as bs
import pandas as pd

list_ticker=[]
for i in range(8):
    url=f'https://finance.yahoo.com/cryptocurrencies?count=25&offset={i*25}'
    r= requests.get(url)
    soup=bs(r.text,"html.parser")
    for i in range(25):
        list_ticker.append(soup.find_all('a', {'class': 'Fw(600) C($linkColor)'})[i].text)

它不起作用。 我可以使用此库解决这个问题吗?

提前致谢!

I am trying to web scrape tickers from the Yahoo Fiance website for crypto-currencies.
However I can't tackle the pagination problem.
I have tried to loop on the count and offset parameters in the url this way:


import requests
from bs4 import BeautifulSoup as bs
import pandas as pd

list_ticker=[]
for i in range(8):
    url=f'https://finance.yahoo.com/cryptocurrencies?count=25&offset={i*25}'
    r= requests.get(url)
    soup=bs(r.text,"html.parser")
    for i in range(25):
        list_ticker.append(soup.find_all('a', {'class': 'Fw(600) C($linkColor)'})[i].text)

It does not work.
Can I solve this problem using this library?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文