最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Scrapy Splash Form Request method is not POST - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a comment  | 

2 Answers 2

Reset to default 0

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)

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.

发布评论

评论列表(0)

  1. 暂无评论