我很想看看是否有什么问题可以从这个页面- https://nreca.csod.com/ux/ats/careersite/4/home?c=nreca#/requisition/182获得动态作业内容。
为了让splash接收URL片段,您必须使用一个SplashRequest。为了让它处理JS cookie,我不得不使用lua脚本。下面是我的环境、脚本和刮擦代码。
该网站似乎以3“步骤”呈现:
如果您在URL上做了一个简单的获取(即在postman中),您将只看到步骤1的内容。使用splash,我只得到步骤2(页眉/页脚)的结果。我确实在response.cookiejar中看到了JS曲奇
我无法获得动态作业内容(步骤3)来呈现。
环境:
刮伤1.3.3刮伤-溅出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'}
},
)发布于 2018-07-23 16:27:15
这必须是默认情况下在私有浏览模式下运行的启动(特别是不允许访问window.localStorage)的问题。这通常会导致javascript异常发生。尝试使用--disable-private-mode选项启动启动,或参考以下文档条目:http://splash.readthedocs.io/en/stable/faq.html#disable-private-mode。
https://stackoverflow.com/questions/51483008
复制相似问题