Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrapy: sending http requests and parse response

Tags:

http

scrapy

i have looked at scrapy docs , but Can scrapy send http form (Ex: user name , password ,....) and parse the result of sending this form ?

like image 602
right.sowrd Avatar asked Jun 08 '26 04:06

right.sowrd


1 Answers

There's an example in the same page : http://scrapy.readthedocs.org/en/latest/topics/request-response.html#passing-additional-data-to-callback-functions

def parse_page1(self, response):
    item = MyItem()
    item['main_url'] = response.url
    request = Request("http://www.example.com/some_page.html",
                      callback=self.parse_page2)
    request.meta['item'] = item
    return request

def parse_page2(self, response):
    item = response.meta['item']
    item['other_url'] = response.url
    return item

You have just to pass a callback parameter function to the request and then, parse the result in parse_page2 ;)

like image 148
Maxime Lorant Avatar answered Jun 10 '26 10:06

Maxime Lorant



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!