0

I am trying to use Proxies for my WebScraping Project, which i did build with HTTPX. However when i was setting up my proxies i still got blocked, so i tryed out if the actully work/get used. I bought some proxys from an professional website/seller, so they work just fine.

I found a website, which returns the IP, from which i am making the request. I Tryed to test the USE of proxies like that:

import httpx
import requests

#Username:PW:Hostname
proxies = {"http://": "http://username:pw.io:hostname"}


#response = requests.get('http://ipinfo.io/json',proxies=proxies)
response = httpx.get('http://ipinfo.io/json',proxies=proxies)

print(response.text)

Both requests and httpx dont work for me, as the response always returns my real IP. How do i need to set up my Proxiex? Keep in mind, that i actually want to use HTTPX and just used requests for debugging aswell.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
MrRementer
  • 21
  • 3
  • 1
    `http://` is not a valid protocol value to be passed as a key in the `dict` for the `proxies` keyword argument; seems you meant just `"http"`. This is a duplicate of [Proxies with Python 'Requests' module](https://stackoverflow.com/questions/8287628/proxies-with-python-requests-module) – esqew Dec 19 '22 at 19:51

1 Answers1

0

How about if try to send the request to verify IP address without proxy first (like using WhatIsMyIP tools and other else), and then send the request through proxy

import httpx

proxy_url = "http://username:pw.io:hostname"
proxies = {"http://": proxy_url, "https://": proxy_url}

# Verify our IP address without proxy first to this website
response = httpx.get("https://www.whatismyip.com/")
print("IP address without proxy:", response.text)

# And then we request through proxy
with httpx.Client(proxies=proxies) as client:
    response = client.get("https://www.whatismyip.com/")
    print("IP address with proxy:", response.text)

If the proxy is working correctly, the IP address that displayed should be different with the previous one