Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check IP address used for a request Python/Scrapy + ProxyMesh

I started to use ProxyMesh with Scrapy. ProxyMesh is supposed to provide a pool of IP addresses on one port. The sample code code below is being repeated in a loop, middleware is enabled and overall this works fine. Can I track (and if so - how?) which IP address is being used for each specific request?

request = scrapy.Request(producturl, self.parse_product_info)
request.meta['proxy'] = 'http://uk.proxymesh.com:xxx'
yield request

I found similar posts on SOF, but not addressing this specific question.

like image 425
Turo Avatar asked Oct 24 '15 23:10

Turo


1 Answers

Like specified in the comments, the information comes on the response headers, just check it:

def parse_response(self, response):
    print response.headers

You should see the X-Proxymesh-Ip header with the assigned proxy.

Another alternative could be to use crawlera which offers even more features (like headers, sessions and cookie handling) and better documentation.

like image 144
eLRuLL Avatar answered Oct 25 '22 09:10

eLRuLL