0

So basically I'm working on a script that searches for available 3 letter Xbox names and to make it more efficient, I made it so that every username that gets checked is appended into an array so that whenever a new name is generated if the name has already been checked it won't bother to send a request out to check it again. However, this feature just simply doesn't work, and I see no issues in my code. Any help would be appreciated, thanks.

import requests, random, string, multiprocessing
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
shtuf = 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
Checked = []
def _3_letter_check_mixed():
    print('starting 3 letter check (mixed)')
    while True:
        user = str(random.choice(string.ascii_letters)).lower() + str(shtuf[random.randrange(35)]).lower() + str(shtuf[random.randrange(35)]).lower()
        proxie_list = []
        with open("https.txt", "r") as f:                   
            for proxy in f.readlines():
                proxie_list.append(proxy.replace("\n", ""))
        proxies = {
           'https://': random.choice(proxie_list)
        }
        if user not in Checked:
            Checked.append(user)
            try:
                r = requests.get(f'https://xboxgamertag.com/search/{user}', headers=headers, proxies=proxies, timeout=5)
            except:
                print('REQUEST FAILED')
            if r.status_code == 404:
                with open('usernames.txt', 'a') as t:
                    print(f'{user} : AVAILABLE')
                    t.write(user + '\n')
            else:
                print(f'{user} : taken')
def _3_letter_check_letter_only():
    print('starting 3 letter check')
    while True:
        user = random.choice(string.ascii_letters).lower() + random.choice(string.ascii_letters).lower() + random.choice(string.ascii_letters).lower()
        proxie_list = []
        with open("https.txt", "r") as f:                   
            for proxy in f.readlines():
                proxie_list.append(proxy.replace("\n", ""))
        proxies = {
           'https://': random.choice(proxie_list)
        }
        if user not in Checked:
            Checked.append(user)
            try:
                r = requests.get(f'https://xboxgamertag.com/search/{user}', headers=headers, proxies=proxies, timeout=5)
            except:
                print('REQUEST FAILED')
            if r.status_code == 404:
                with open('usernames.txt', 'a') as t:
                    print(f'{user} : AVAILABLE')
                    t.write(user + '\n')
            else:
                print(f'{user} : taken')
     
processes = []
for i in range(5):
    p = multiprocessing.Process(target=_3_letter_check_mixed)
    if __name__ == "__main__":
        p.start()
        processes.append(p)
for i in range(5):
    p = multiprocessing.Process(target=_3_letter_check_letter_only)
    if __name__ == "__main__":
        p.start()
        processes.append(p)
for p in processes:
    p.join()
zJackk
  • 1
  • 1
  • Does this answer your question? [multiprocessing global variable updates not returned to parent](https://stackoverflow.com/questions/11055303/multiprocessing-global-variable-updates-not-returned-to-parent) – Mike Scotty Oct 08 '21 at 14:21
  • Each of your processes has its own private copy of `Checked`. Anything you add in one process won't be seen (and therefore won't prevent a duplicate request) in any of the other processes. – jasonharper Oct 08 '21 at 14:22
  • @jasonharper is there a way to fix this? – zJackk Oct 08 '21 at 14:32
  • The easiest solution would probably be to pick the random names entirely in the main process, where they can all access the same `Checked` list (or better yet, a set, for more efficient lookups). Only do the requests (which is the part that benefits from parallel processing) in your subprocesses. – jasonharper Oct 08 '21 at 14:37

0 Answers0