gpt4 book ai didi

python - 想要抓取所有成员(member)个人资料链接以获取成员(member)详细信息

转载 作者:太空宇宙 更新时间:2023-11-03 21:07:49 26 4
gpt4 key购买 nike

from bs4 import BeautifulSoup
import requests
r = requests.get('http://medicalassociation.in/doctor-search')
soup = BeautifulSoup(r.text,'lxml')

link = soup.find('table',{'class':'tab-gender'})
link1 = link.find('tbody')
link2 = link1.find('tr')[3:4]
link3 = link2.find('a',class_='user-name')
print link3.text

无法通过此代码获取链接。我想取出查看个人资料链接

最佳答案

以下内容适用于我的多次测试运行。只需使用 requestsselect 以及类选择器即可。

import requests
from bs4 import BeautifulSoup as bs

r = requests.get('http://medicalassociation.in/doctor-search')
soup = bs(r.content, 'lxml')
results = [item['href'] for item in soup.select(".user-name")]
print(results)

关于python - 想要抓取所有成员(member)个人资料链接以获取成员(member)详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55284302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com