Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrapy: Can I extract request formdata from response?

Tags:

scrapy

I am using scrapy to scrape some data, I am wondering how much data of Request the Response stores.

My specific question is shown in the following code:

def parse(self,response):
    r = FormRequest(url=url1, formdata={somedata}, callback=parse2)

    #is this line necessary if I want the formdata being attached?
    r.meta['formdata'] = formdata

    yield r

def parse2(self,response):
    #can I access to the formdata here without that line of code?

Any suggestion would be appreciated.

like image 517
user3182473 Avatar asked Sep 21 '25 02:09

user3182473


1 Answers

Yes, however formdata is already converted into body and won't be the dictionary but a string as far as I remember.

so try r.body also quick reminder you can check the attributes of an object by: dir(r)

like image 58
Granitosaurus Avatar answered Sep 23 '25 12:09

Granitosaurus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!