我试图搜集一个网站的研究成果,该网站列出了法国众贷金融科技公司:https://www.orias.fr/web/guest/search
手动操作时,我在单选按钮中选择(IFP),然后它为我提供13个结果页,每页10个结果。每一个结果都有一个超链接,我也想从中得到信息,进入最后的表格。你知道吗
我的主要问题似乎来自CSRF,在结果地址中,有: 认证=8mxk0SsK 因此,我不能简单地通过将链接中的“p=2”更改为“p=13”来循环浏览结果页: https://www.orias.fr/search?p_auth=8mxk0SsK&p_p_id=intermediaryDetailedSearch_WAR_oriasportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_intermediaryDetailedSearch_WAR_oriasportlet_myaction=fullSearch
所以我试着在python代码中使用它:
import requests
from bs4 import BeautifulSoup
k = 1
% test k from 1 to 13
url = "http://www.orias.fr/search?p_p_id=intermediaryDetailedSearch_WAR_oriasportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_intermediaryDetailedSearch_WAR_oriasportlet_d-16544-p=" + str(k) + "&_intermediaryDetailedSearch_WAR_oriasportlet_implicitModel=true&_intermediaryDetailedSearch_WAR_oriasportlet_spring_render=searchResult"
response = requests.get(url, proxies=proxies) # 200 ment it went through
soup = BeautifulSoup(response.text, "html.parser")
table = soup.find('table', attrs={'class':'table table-condensed table-striped table-bordered'})
table_rows = table.find_all('tr')
l = []
for tr in table_rows:
td = tr.find_all('td')
row = [tr.text for tr in td]
l.append(row)
它不像在web浏览器中那样工作,它只是提供一个页面,就好像没有请求任何结果一样。你知道怎么做吗?你知道吗
所以这里是完整的代码,同时也考虑到“每个结果都有一个超链接,我也想从中获取信息到最终的表中”。因此,对于每家公司,我更新和标题,然后刮注册或删除日期。可能有一种更优雅的方式来呈现代码。。。你知道吗
我会在循环期间更改post请求中的page参数。做一个初始请求以找出页数
检查:
相关问题 更多 >
编程相关推荐