DMGM
DMGM

Reputation: 1

Proxies in the get method of requests module dont seem to work

I've googled the syntax for proxies and it should be the same as in my code and there is no other way around but anyways, after using proxies, https://api.ipify.org still returns my own external ip address.

import requests
import random


def get_site():
    http = ['85.26.146.169:80', '85.143.70.165:80', '213.135.118.150:3128']
    proxi = {
        'http': 'http://'+random.choice(http)
    }
    # proxi = {
    #     'http': 'http://85.26.146.169:80'
    # }
    print(requests.get('https://api.ipify.org', proxies=proxi).text)

get_site()

both commented and uncommented variants dont work

P.S. after changing protocol from http to https now it is working but I doubt that every single one from 18 proxies doesnt work and also i can easily ping them. they're free though

import requests
import random


def get_site():
    https = ['188.134.65.80:41890', '77.236.243.69:1256', '31.163.192.161:3129', '37.110.6.178:8080',
             '31.131.67.14:8080', '77.238.129.14:55443', '85.235.184.186:3129', '195.133.71.199:8080',
             '95.189.104.181:41890',
             '78.36.198.158:80',
             '188.246.186.142:41890',
             '95.140.31.39:41890',
             '178.74.103.46:8080',
             '212.46.255.78:8080',
             '195.68.187.222:3128',
             '81.24.95.176:41258',
             '89.22.152.32:53726',
             '84.201.254.47:3128']
    for i in range(len(https)):
        proxi = {
            'https': 'https://' + https[i]
        }
        print(requests.get('https://api.ipify.org', proxies=proxi).text)

Upvotes: 0

Views: 377

Answers (0)

Related Questions