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, however when I access a site that shows the IP used in the request, it shows the IP of my computer.
I am using a free Proxy I found online.
Here is my code:
import requests
proxy = {'SOCKS5': '24.145.195.60:27595'}
response = requests.get('http://www.whatsmyip.de/', proxies=proxy)
print response
Any help is greatly appreciated!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With