Skip to content

Instantly share code, notes, and snippets.

@SyedAhkam
Last active August 24, 2023 12:36
Show Gist options
  • Save SyedAhkam/f99e68c2bbb89c11202e6c53de21a10a to your computer and use it in GitHub Desktop.
Save SyedAhkam/f99e68c2bbb89c11202e6c53de21a10a to your computer and use it in GitHub Desktop.
Scrape whatsapp group contact numbers
// Make this false if need to remove named contacts
const REMOVE_NAMES = true;
let numbers = document.querySelector("#main > header > div:nth-child(2) > div:nth-child(2) > span").title.split(",").map(e => e.trim());
if (REMOVE_NAMES) {
numbers = numbers.filter(name => name.startsWith("+"));
}
console.log(numbers);
// Save to a txt file
const blob = new Blob([numbers.join("\n")], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "scraped_numbers.txt"; // can make this csv as well
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment