因此,我试图在这个网站上刮开放的立场,当我使用任何类型的请求(目前正在尝试请求html),它不会显示所有的html中的内容。你知道吗
# Import libraries
import time
from bs4 import BeautifulSoup
from requests_html import HTMLSession
# Set the URL you want to webscrape from
url = 'https://germanamerican.csod.com/ux/ats/careersite/5/home?c=germanamerican'
session = HTMLSession()
# Connect to the URL
response = session.get(url)
response.html.render()
# Parse HTML and save to BeautifulSoup object¶
soup = BeautifulSoup(response.text, "html5lib")
b = soup.findAll('a')
不知道去哪儿。最初认为问题是由于javascript呈现造成的,但这不起作用。你知道吗
我认为不可能用请求来刮那个网站。 我建议使用硒或刮痧。你知道吗
问题是,初始GET没有获取数据(我假设是工作列表),而执行此操作的js在头中使用了带有授权令牌的POST。你需要得到这个令牌,然后进行POST来获取数据。你知道吗
这个标记看起来是动态的,所以我们会有点不确定,但可行。你知道吗
打印出来的
r.json()
是一个很好的json格式的工作列表表。你知道吗欢迎来到SO!你知道吗
不幸的是,您将无法使用
requests
(也不能使用requests_html
或类似的库)刮取该页面,因为您需要一个工具来处理动态页面,即基于javascript的页面。你知道吗对于python,我强烈建议使用
selenium
及其webdriver
。下面是一段打印所需输出的代码,即所有列出的作业(注意,需要安装selenium
和Firefox webdriver,并使用正确的运行路径)相关问题 更多 >
编程相关推荐