Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python Request's Proxies not working.

I'm trying to use requests with proxies, but it only shows my local IP

Here's my test code.

Code
#!/usr/bin/python3

import requests
import random
impo


proxies = [
    "167.172.248.53:3128",
    "194.226.34.132:5555",
    "203.202.245.62:80",
    "141.0.70.211:8080",
    "118.69.50.155:80",
    "201.55.164.177:3128",
    "51.15.166.107:3128",
    "91.205.218.64:80",
    "128.199.237.57:8080",
]


def get_session(proxies):
    session = requests.Session()
    proxy = random.choice(proxies)
    session.proxies = {"http://": proxy, "https://": proxy}
    return session, proxy


for i in range(5):
    s, proxy = get_session(proxies)
    try:
        print(
            f"Proxying through {proxy}:",
            s.get("http://icanhazip.com", timeout=1.5).text.strip(),
        )
    except Exception as e:
        continue
I

Code
Proxying through 141.0.70.211:8080: 51.25x.xxx.193
Proxying through 201.55.164.177:3128: 51.25x.xxx.193
Proxying through 91.205.218.64:80: 51.25x.xxx.193
Proxying through 141.0.70.211:8080: 51.25x.xxx.193
Proxying through 51.15.166.107:3128: 51.25x.xxx.193


Any idea's on why this is not working?
I don't think you can do session.proxies, I think you have to do s.get('', proxies=proxy)
i like python lua js
(May 1, 2020 05:54 AM)Riԁdle Wrote:  I don't think you can do session.proxies, I think you have to do s.get('', proxies=proxy)

It's unnecessary to begin with. Just use HTTP Basic Auth with your proxy:

Code
proxies = {
    "http": "http://167.172.248.53:3128",
}

[Image: qZ42qWp.jpg]



Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by kille142Oct 25, 2016 06:28 AM 3 150 Oct 25, 2016 06:28 AM
Last Post: M5DD
[Python] by FastFiveSep 2, 2013 02:57 PM 1 127 Sep 2, 2013 02:57 PM
Last Post: tux1