Ste*_*eve 1 python screen-scraping splash-screen scrapy reactjs
我很想知道是否有任何飞溅可以从此页面获取动态工作内容 - https://nreca.csod.com/ux/ats/careersite/4/home?c=nreca#/requisition/182
为了让 splash 接收 URL 片段,您必须使用 SplashRequest。为了让它处理 JS cookie,我不得不使用 lua 脚本。下面是我的环境、脚本和爬虫代码。
该网站似乎分 3 个“步骤”呈现:
如果您对 URL 执行简单的 GET(即在邮递员中),您将只会看到第 1 步的内容。与飞溅我只得到第 2 步的结果(页眉/页脚)。我确实在 response.cookiejar 中看到了 JS cookie
我无法获得要呈现的动态作业内容(第 3 步)。
环境:
scrapy 1.3.3 scrapy-splash 0.72 设置
script = """
function main(splash)
splash:init_cookies(splash.args.cookies)
assert(splash:go{
splash.args.url,
headers=splash.args.headers,
http_method=splash.args.http_method,
body=splash.args.body,
})
assert(splash:wait(15))
local entries = splash:history()
local last_response = entries[#entries].response
return {
url = splash:url(),
headers = last_response.headers,
http_status = last_response.status,
cookies = splash:get_cookies(),
html = splash:html(),
}
end
"""
return SplashRequest('https://nreca.csod.com/ux/ats/careersite/4/home?c=nreca#/requisition/182',
self.parse_detail,
endpoint='execute',
cache_args=['lua_source'],
args={
'lua_source': script,
'wait': 10,
'headers': {'User-Agent': 'Mozilla/5.0'}
},
)
Run Code Online (Sandbox Code Playgroud)
小智 6
这一定是默认情况下在隐私浏览模式下运行的启动问题(特别是不允许访问window.localStorage)。这通常会导致 javascript 异常发生。尝试使用--disable-private-mode选项启动启动或参考此文档条目:http : //splash.readthedocs.io/en/stable/faq.html#disable-private-mode。
| 归档时间: |
|
| 查看次数: |
2205 次 |
| 最近记录: |