Skip to content

Instantly share code, notes, and snippets.

@arunshaji95
Last active January 24, 2018 08:24
Show Gist options
  • Save arunshaji95/5a1e60bbc21f5056ee7dfc6da80c66ef to your computer and use it in GitHub Desktop.
Save arunshaji95/5a1e60bbc21f5056ee7dfc6da80c66ef to your computer and use it in GitHub Desktop.
Scrapy post request example

Scrapy post request example

We can use python scrapy.FormRequest send post request with parameters.

import scrapy

class ExampleSpider(scrapy):
    name = 'ExampleSpider'
    allowed_domains = ['example.com']

    def start_requests(self):
        params = {
            'parameter1': 'value1',
            'parameter2': 'value2',
        }
        yield scrapy.FormRequest('api.example.com', callback=self.parse,
                                 method='POST', formdata=params)

    def parse(self, response):
        pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment