I use this request to do form request using scrapy splash, but it said the method was NONE and Splash can only process GET and POST
yield SplashFormRequest(url,
args={'wait': 5,
'http_method':"POST",
'body' : body,
'cookies':cookie},
headers=headers,
callback=self.parse_listings,
dont_filter=True)
How to make it POST method?
I use this request to do form request using scrapy splash, but it said the method was NONE and Splash can only process GET and POST
yield SplashFormRequest(url,
args={'wait': 5,
'http_method':"POST",
'body' : body,
'cookies':cookie},
headers=headers,
callback=self.parse_listings,
dont_filter=True)
How to make it POST method?
Share Improve this question asked Feb 16 at 6:08 Aminah NurainiAminah Nuraini 19.2k9 gold badges97 silver badges113 bronze badges2 Answers
Reset to default 0When I open the source code of SplashFormRequest, their code is inconsistent with SplashRequest. SplashRequest declares the method in args, while SplashFormRequest declares the method like a standard Scrapy Request. I fixed it by rewriting it like this.
yield SplashFormRequest(url,
method="POST",
args={'wait': 5,
'body' : body,
'cookies':cookie},
headers=headers,
callback=self.parse_listings,
dont_filter=True)
You haven't passed formdata
to SplashFormRequest
, and so you don't actually need SplashFormRequest
. If you passed formdata
you wouldn't get this error because FormRequest
sets method
to POST
if it's None and formdata
is passed.