S
S
ssick132019-09-01 11:26:20
Python
ssick13, 2019-09-01 11:26:20

Proxy requests?

try:
   f=open('proxy.txt','r')
except IOError:
   print("Error. File './%s' not found!")
   sys.exit(1)
pr_list=f.readlines()
while i < len(pr_list):
    proxyDict = { 
              "https"  : pr_list[i].strip()
            }
  print(requests.post('https://2ip.ru',proxies=proxyDict))

In a text document I have:
125.164.3.220:8080
125.24.100.94:8080
185.131.62.250:53281
With this code I get an error:
no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'str 'object has no attribute 'get'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2019-09-01
@ssick13

import os
import requests

file_with_proxy = './p.txt'

if os.path.isfile('file_with_proxy'):
  with open(file_with_proxy, 'r') as p_f:
    for p in p_f:
       print(requests.post('https://2ip.ru', proxies={'http': p.strip()}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question