0

I am trying to run a script and it has a standard URL for proxies which allows the script to run fine. Once I add my own proxy URL I am getting the error Error: proxy = next(proxy_pool) StopIteration. My URL is in another file and I can also link that if needed. Code is below, if anyone can help that would be great.

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)
 ``
Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Looks like `proxies` is empty. – Klaus D. Dec 28 '21 at 05:20
  • I am not sure whats up as this is my proxy script and My URL dumps a list. Ill add the code below – Robby Analog Dec 28 '21 at 05:27
  • from lxml.html import fromstring import requests import traceback def get_proxies(): url = 'https://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")]'): proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]]) proxies.add(proxy) return proxies – Robby Analog Dec 28 '21 at 05:28

1 Answers1

0

Try this code for 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

Output here

BlackCat
  • 19
  • 1
  • 5
  • Well you got me 1 step closer! Thanks so much, I am now getting spammed with BAD PROXY as it must not be liking my format?? Not sure if you know why it would be spitting bad proxy but any help would be great – Robby Analog Dec 28 '21 at 05:53
  • I am also only able to choose 100 tokens when I should be able to go 10,000+ so my gues would be it does not know my proxies are rotating, Plus it thinks theyr BAD PROXYS Much appreciated – Robby Analog Dec 28 '21 at 05:56
  • ACtually It seems this is my error requests.exceptions.SSLError: HTTPSConnectionPool(host='discordapp.com', port=443): Max retries exceeded with url: /api/v6/users/@me/library (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))) – Robby Analog Dec 28 '21 at 06:14
  • **NOT RECOMENDED** add parameter `verify = None` to your request `r = requests.get (url, headers = header, proxies = {'https': "http: //" + proxy}, verify = None)` – BlackCat Dec 28 '21 at 07:06
  • This looks like a solution to your problem. [link](https://stackoverflow.com/a/14146031/9516034) – BlackCat Dec 28 '21 at 07:14