使用代理的代码irequest在哪里出错?

时间:2019-03-22 14:36:11

标签: python-3.x proxy request

这是我的代码,我想在它使用不同代理的每个请求上使用它,但不要这样做。有问题的人可以帮助解决这个错误。 使用我的代码,它总是在多代理中使用相同的URL,但是我只想在1个代理中使用相同的URL,然后从URL列表中使用第二个URL,并从代理列表中使用第二个

import os, re, sys, socket, binascii, time, json, random, threading, getpass
import requests     

def get_proxies(url):
    urls = 'https://www.proxy-list.download/api/v1/get?type=https'
    Headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0'
    }
    source = requests.get(urls, timeout=5, headers=Headers).text
    with open('proxy.txt', 'a') as writer:
        writer.write(source+'\n')
    proxylist = open('proxy.txt','r').readlines()
    for proxy in proxylist:
        proxy = proxy.rstrip()
        proxys = proxy
        proxies = {
        'https': proxys,
        }
        print("Scanning -> "+url+'='+proxys)
        s = requests.Session()
        s.proxies = proxies
        r = s.get('https://api.hackertarget.com/reverseiplookup/?q='+url).text
        with open('rev.txt', 'a') as writer:
             writer.write(r+'\n')


def passfor():      
    list = open(input("List : "),'r').readlines()
    for url in list:
        try:
           url = url.rstrip()       
           data=get_proxies(url)
        except:
            pass                   
        get_proxies(url)

Passwd = getpass.getpass("Give Passwd : ")
if "" in Passwd:
    passfor()
else:
    exit()

0 个答案:

没有答案