Last active
March 18, 2022 11:20
-
-
Save nemesis64/e831f8b52eecdc40cc1476cd410309e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace scraper | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int counter = 1; | |
string token = ""; | |
WebClient scraper = new WebClient(); | |
if (File.Exists("token.txt")) | |
{ | |
token = File.ReadAllText("token.txt"); | |
} | |
else | |
{ | |
Console.Write("Token: "); | |
token = Console.ReadLine(); | |
} | |
scraper.Headers.Add("Authorization: " + token); | |
Console.Write("Server ID: "); | |
string serverid = Console.ReadLine(); | |
string response = scraper.DownloadString("https://discordapp.com/api/guilds/" + serverid + "/members?limit=1000").Replace("\"", string.Empty); | |
var hashes = Regex.Matches(response, @"id: [0-9]{18}, avatar: [A-Za-z0-9]{32}"); | |
Console.WriteLine("Found {0} avatars. Downloading...", hashes.Count); | |
if (!Directory.Exists("avatars")) | |
{ | |
Directory.CreateDirectory("avatars"); | |
} | |
Parallel.For(0, hashes.Count, i => { | |
string id = hashes[i].ToString().Replace("id: ", string.Empty).Substring(0, 18); | |
string hash = hashes[i].ToString().Remove(0, 32); | |
WebClient downloader = new WebClient(); | |
downloader.DownloadFile(string.Format("https://cdn.discordapp.com/avatars/{0}/{1}.png?size=1024", id, hash),"avatars/" + hash + ".png"); | |
Console.WriteLine("Downloaded hash {0} | {1}/{2}", hash,counter++,hashes.Count); | |
downloader.Dispose(); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment