10

I want to crawl a website which supports only post data. I want to send the query params in post data in all the requests. How to achieve this?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
nizam.sp
  • 4,002
  • 5
  • 39
  • 63

1 Answers1

15

POST requests can be made using scrapy's Request or FormRequest classes.

Also, consider using start_requests() method instead of start_urls property.

Example:

from scrapy.http import FormRequest

class myspiderSpider(Spider):
    name = "myspider"
    allowed_domains = ["www.example.com"]

    def start_requests(self):
        return [ FormRequest("http://www.example.com/login",
                     formdata={'someparam': 'foo', 'otherparam': 'bar'},
                     callback=self.parse) ]

Hope that helps.

KrisWebDev
  • 9,342
  • 4
  • 39
  • 59
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195