Requests Proxy Not Working
I am currently writing a scraper for testing want to access the site with a different IP, I have found a lot of information about using a proxy and tried this several times, howeve
Solution 1:
You need to define a proxy for the HTTP
and or a HTTPS
protocol. I'm not sure if requests
works with SOCKS
protocol yet
This works for me.
import requests
import bs4
proxy = {"http": "115.227.195.213"}
response = requests.get('http://www.whatsmyip.de/', proxies=proxy)
soup = bs4.BeautifulSoup(response.text)
print soup.h3.text
Note: It uses the bs4 module to print the ip and I used a proxy server that is HTTP
compatible
Post a Comment for "Requests Proxy Not Working"