我有以下url https://www.gbgb.org.uk/greyhound-profile/?greyhoundId=517801,其中最后6位数字是特定跑步者的唯一标识符。我想找到这个页面上所有的6位唯一标识符
我曾尝试在页面上刮取所有URL(代码如下所示),但不幸的是,我只得到了一个高级摘要。而不是包含>;5000名跑步者。我希望得到一个列表/数据框,其中显示:
https://www.gbgb.org.uk/greyhound-profile/?greyhoundId=517801
https://www.gbgb.org.uk/greyhound-profile/?greyhoundId=500000
https://www.gbgb.org.uk/greyhound-profile/?greyhoundId=500005
等等
这就是我到目前为止所能做到的。谢谢你的帮助
from bs4 import BeautifulSoup
from urllib.request import Request, urlopen
import re
req = Request("https://www.gbgb.org.uk//greyhound-profile//")
html_page = urlopen(req)
soup = BeautifulSoup(html_page, "lxml")
links = []
for link in soup.findAll('a'):
links.append(link.get('href'))
print(links)
提前谢谢你的帮助
您可以将结果内容转换为数据帧,然后只需使用winnerOr2ndName和winnerOr2ndId列即可
范例
它将生成如下所示的数据帧:
从外部API URL调用加载数据。您可以使用下一个示例来加载数据(使用ID):
印刷品:
相关问题 更多 >
编程相关推荐