L
L
LordOftheCode2021-10-07 09:48:28
Python
LordOftheCode, 2021-10-07 09:48:28

Problem with proxy in python, how to fix?

My code:

proxy_list = []
with open("proxy.txt") as inp:
    for line in inp:
        proxy_list.append(line)

for prx in proxy_list:
  print(prx)
  ses.proxies = prx
  ses.get("https://2ip.ru")
  soup = BeautifulSoup(r.text, 'lxml')
  prx = soup.find('div', {'class' : 'ip'})


Here I get cookies with this format from a text file
88.88.88.88:888
and when using a proxy, an error appears
615e983939058715044731.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2021-10-07
@LordOftheCode

Proxies must be loaded in a different format
https://docs.python-requests.org/en/latest/user/ad...

proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}

V
Vindicar, 2021-10-07
@Vindicar

ses.proxies = prx
Plural - "proxies"... Maybe he wants a list of proxies and will look for the first worker?
EDIT: no, he needs a dictionary of proxies for different protocols .

A
Anastasia_K, 2021-10-07
@Anastasia_K

ses.proxies = [prx]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question