Aminah Nuraini
Aminah Nuraini

Reputation: 19196

Scrapy Splash Form Request method is not POST

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?

Upvotes: 0

Views: 31

Answers (2)

wRAR
wRAR

Reputation: 25559

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.

Upvotes: 0

Aminah Nuraini
Aminah Nuraini

Reputation: 19196

When 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)

Upvotes: 0

Related Questions