scrapy - scrapy-splash response.body 不包含 html
问题描述
我试图在启动本地实例的同时使用 crawlera,这是我的 lua 脚本
function main(splash)
function use_crawlera(splash)
local user = splash.args.crawlera_user
local host = 'proxy.crawlera.com'
local port = 8010
local session_header = 'X-Crawlera-Session'
local session_id = 'create'
splash:on_request(function(request)
request:set_header('X-Crawlera-Cookies', 'disable')
request:set_header(session_header, session_id)
request:set_proxy { host, port, username = user, password = '' }
end)
splash:on_response_headers(function(response)
if type(response.headers[session_header]) ~= nil then
session_id = response.headers[session_header]
end
end)
end
function main(splash)
use_crawlera(splash)
splash:go(splash.args.url)
splash:wait(30)
return splash:html()
end
结尾
这是我的 start_request
yield SplashRequest(index_url,
self.parse_kawanlama_index,
endpoint='execute',
args={
'lua_source': lua_script,
'wait' : 5,
'html' : 1,
'url': index_url,
'timeout': 10,
'crawlera_user':self.crawlera_apikey
},
# tell Splash to cache the lua script, to avoid sending it for every request
cache_args=['lua_source'],
)
但它似乎不起作用,因为我在 self.parse(response) 中得到的 response.body 不包含 html。
解决方案
推荐阅读
- sql - 如何修复这些触发错误?Oracle 11g 速成版
- c# - VSTO: Event Handler failing to fire after a reboot
- c# - 静态 Equals 方法为值类型返回 False
- bash - 使用 bash 从文本文件中读取最后一行的问题
- java - 从java中的对象获取类列表
- php - 根据我的 WHERE 子句,非 md5 密码的新列未更新
- office365 - 在桌面版 Microsoft Office 365 中旁加载插件
- python-3.x - 使用 Pandas 数据阅读器从 Stooq 导入数据在 Python 中返回空数据框,但在笔记本中有效
- css - 为什么 flex 容器会有这样的行为
- jenkins - Jira Integration for Jenkins 新创建问题