python 3.x - Requests: Check that the proxy has been used to make the HTTP Request -
i've been scratching head whole day yesterday , surprise, can't seem find easy way check this.
i using python's requests library pass proxy such as:
def make_request(url): requests.session() s: s.mount("http://", httpadapter(max_retries=3)) s.mount("https://", httpadapter(max_retries=3)) page = none d.rotate(-1) #d contains dict of proxies. allows rotate through proxies everytime make_request called. s.proxies = d[0] page = s.get(url, timeout=3) print('proxy used: ' + str(d[0])) return page.content
problem is, can't seem make request fail when proxy not expected work. seems there fallback on internet ip if proxy not working. example: tried passing random proxy ip 101.101.101.101:8800 or removing ip authentication needed on proxies, request still passed, though should'nt.
i thought adding timeout parameters when passing request trick, didn't.
so 1/ why happen? 2/ how can check ip request being made?
thank you!
Comments
Post a Comment