from bs4 import BeautifulSoup
import requests
r = requests.get('http://iacts.org/members/')
soup = BeautifulSoup(r.text,'lxml')
for link in soup.find('div',id_='members-dir-list'):
for link1 in link.find_all('div',class_='item'):
for link2 in link1.find_all('a'):
for link3 in link2.find('href'):
print link3.text
未获得会员链接,想从给定站点中删除会员个人资料链接。
答案 0 :(得分:1)
请尝试以下代码。您可以打开chrome开发人员工具(F12),然后单击“搜索”按钮,查看发送到过帐请求的表单数据。然后,通过在请求中传递数据来模拟请求。
az login
结果:
import requests
import lxml
from lxml import html
data = {
"iacts_search": "Search",
"bp_profile_search": "true"
}
r = requests.post('http://iacts.org/members/', data=data)
tree = html.fromstring(r.content)
member_list = tree.xpath('//*[@id="members-list"]//div[@class="item-title"]//a')
# print(len(member_list))
for member in member_list:
print(member.get('href'))