用BeautifulSoup刮网:获取资金

2024-09-25 18:24:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用beautifulsoup每天从fundsupermarthttps://www.fundsupermart.co.in/main/research/recommendedFundsNew.svdo获取推荐资金?但我无法获得基金的类别和其他属性。你知道吗

当我使用select语句时
汤.选择('.table\u bdrow1\u style')

我不了解基金的类别和其他属性。我刚知道基金的名字。有人能帮我吗?你知道吗


Tags: in属性基金mainwww类别select资金
1条回答
网友
1楼 · 发布于 2024-09-25 18:24:57
import requests
from bs4 import BeautifulSoup

r = requests.get('https://www.fundsupermart.co.in/main/research/recommendedFundsNew.svdo')
soup = BeautifulSoup(r.text, 'lxml')
trs = soup.find_all(class_="table_bdrow1_style")

for tr in trs:
    row = list(tr.stripped_strings)
    print(row)

输出:

['BSL FRONTLINE EQUITY FUND- GROWTH', 'Large Cap', '9.69', '3.87', '17.2', '17.01']
['ICICI PRUDENTIAL FOCUSED BLUECHIP EQUITY FUND- GROWTH', 'Large Cap', '9.11', '3.05', '15.34', '14.97']
['SBI BLUE CHIP FUND- GROWTH', 'Large Cap', '7.82', '6.49', '19.69', '18.73']
['AXIS EQUITY FUND- GROWTH', 'Large Cap', '1.08', '-1.44', '11.86', '14.31']
['BNP PARIBAS EQUITY FUND- GROWTH', 'Large Cap', '0.34', '0.89', '14.83', '14.96']
['RELIANCE TOP 200 FUND- GROWTH', 'Large Cap', '5.66', '2.21', '19.39', '17.18']

你知道吗hrml.parse文件版本:

import requests
from bs4 import BeautifulSoup

r = requests.get('https://www.fundsupermart.co.in/main/research/recommendedFundsNew.svdo')
soup = BeautifulSoup(r.content, 'html.parser')
trs = soup.find_all(class_="table_bdrow1_style")

for tr in trs:
    row = list(tr.stripped_strings)
    print(row)

输出:

['BSL FRONTLINE EQUITY FUND- GROWTH']
['ICICI PRUDENTIAL FOCUSED BLUECHIP EQUITY FUND- GROWTH']
['SBI BLUE CHIP FUND- GROWTH']
['AXIS EQUITY FUND- GROWTH']
['BNP PARIBAS EQUITY FUND- GROWTH']
['RELIANCE TOP 200 FUND- GROWTH']

如果您仍然得到错误,请张贴您的代码和错误信息。你知道吗

相关问题 更多 >