├── README.md └── scraper.py /README.md: -------------------------------------------------------------------------------- 1 | # Discord-Username-Scraper 2 | Scrape usernames from big servers to get realistic t0kens when generating 3 | -------------------------------------------------------------------------------- /scraper.py: -------------------------------------------------------------------------------- 1 | import os, requests, random, time 2 | 3 | class Scraper: 4 | 5 | def __init__(self, channel_id, token, amount): 6 | self.token = token 7 | self.channel_id = channel_id 8 | self.usernames = [] 9 | self.amount = amount 10 | self.params = { 11 | 'limit': 100, 12 | } 13 | 14 | def get_usernames(self): 15 | while len(self.usernames) < self.amount: 16 | req = requests.get( 17 | url = f'https://discord.com/api/v9/channels/{self.channel_id}/messages', 18 | params = self.params, 19 | headers = { 20 | 'authority': 'discord.com', 21 | 'accept': '*/*', 22 | 'authorization': f"{self.token}", 23 | 'cache-control': 'no-cache', 24 | 'pragma': 'no-cache', 25 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', 26 | 'x-debug-options': 'bugReporterEnabled', 27 | 'x-discord-locale': 'en-US', 28 | 'x-super-properties': 'eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiQ2hyb21lIiwiZGV2aWNlIjoiIiwic3lzdGVtX2xvY2FsZSI6ImVuIiwiYnJvd3Nlcl91c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwMi4wLjAuMCBTYWZhcmkvNTM3LjM2IiwiYnJvd3Nlcl92ZXJzaW9uIjoiMTAyLjAuMC4wIiwib3NfdmVyc2lvbiI6IjEwIiwicmVmZXJyZXIiOiJodHRwczovL21lZTYueHl6LyIsInJlZmVycmluZ19kb21haW4iOiJtZWU2Lnh5eiIsInJlZmVycmVyX2N1cnJlbnQiOiIiLCJyZWZlcnJpbmdfZG9tYWluX2N1cnJlbnQiOiIiLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjoxMzI4MzEsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9', 29 | } 30 | ) 31 | 32 | for message in req.json(): 33 | username = message['author']['username'] 34 | if username not in self.usernames: 35 | self.usernames.append(username) 36 | print(username, len(self.usernames)) 37 | 38 | self.params = { 39 | 'before': req.json()[-1]['id'], 40 | 'limit': 100 41 | } 42 | 43 | for username in self.usernames: 44 | try: 45 | if '�' not in username: 46 | print(username, file = open('./usernames.txt', 'a')) 47 | except UnicodeEncodeError: 48 | pass 49 | 50 | if __name__ == "__main__": 51 | scrapy = Scraper( 52 | channel_id = 'CHANNEL OF SERVER', 53 | token = 'TOKEN IN SERVER', 54 | amount = 1000 #amount of usernames to scrape 55 | ) 56 | scrapy.get_usernames() 57 | --------------------------------------------------------------------------------