18910140161

Python-Web Scraphing使用嵌入在标记的文本堆栈溢出后面的BeautifulSoup-Link

顺晟科技

2022-10-19 13:21:46

173

我试图从https://eresearch.fidelity.com/eresearch/goto/markets_扇区/landing.jhtml刮取数据。目标是从美国市场获得最新的11个行业的业绩数据。但我不能看到的表现,直到我点击每个扇区。换句话说,每个扇区背后都嵌入了一个链接。我想要一个元组列表,每个元组应该对应于一个扇区,并且应该包含以下数据:扇区名称、扇区移动的数量、扇区的市值、扇区的市场权重以及指向该扇区的保真度页面的链接。

下面是我到目前为止的代码。我被卡住了,我想要得到每个部门的内容的部分。我的代码根本不返回任何东西。请救命!提前谢谢。

    import requests
    from bs4 import BeautifulSoup
    url = "https://eresearch.fidelity.com/eresearch/goto/markets_sectors/landing.jhtml"
    req = requests.get(url)
    soup = BeautifulSoup(req.content, "html.parser")
    
    links_list = list()
    next_page_link = soup.find_all("a", class_="heading1")
    for link in next_page_link:
        next_page = "https://eresearch.fidelity.com"+link.get("href")
        links_list.append(next_page)
    
    for item in links_list:
        soup2 = BeautifulSoup(requests.get(item).content,'html.parser')
        print(soup2)

顺晟科技:

尝试:

打印:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航