request multiple proxy python pip

- Posted in Python by
import random
import requests

proxies_list = [List of IPs]

proxies = {
    'http': random.choice(proxies_list)
}
r = requests.get('http://10.1.7.70:8000', proxies=proxies)

using file bulk proxy

pxies_txt = []
    dirProxy = realPath + "/proxy.txt"
    for line in open(dirProxy):
        words = line.split("\n")
        pxies_txt.extend([string for string in words if string])
    #
    proxies_list = pxies_txt
    try:
        proxies = {'https' : random.choice(proxies_list)}
        link = requests.get(link, proxies=proxies, timeout=300)

    #jika koneksi error 
    ##
    except requests.exceptions.ConnectionError as e: 

https / http

http_proxy  = "http://10.10.1.10:3128"
https_proxy = "https://10.10.1.11:1080"
ftp_proxy   = "ftp://10.10.1.10:3128"

proxyDict = { 
              "http"  : http_proxy, 
              "https" : https_proxy, 
              "ftp"   : ftp_proxy
            }

r = requests.get(url, headers=headers, proxies=proxyDict)

s_https://stackoverflow.com/questions/8287628/proxies-with-python-requests-module

s_https://stackoverflow.com/questions/36446657/requests-multiple-proxies-python