Skip to content

Instantly share code, notes, and snippets.

@filipechagas
Last active September 5, 2024 18:33
Show Gist options
  • Save filipechagas/f8ca247b0e4096bd83ca97aa16c06638 to your computer and use it in GitHub Desktop.
Save filipechagas/f8ca247b0e4096bd83ca97aa16c06638 to your computer and use it in GitHub Desktop.
Twitter Followers Inspector-Scrapping
// Source: https://x.com/FelippeRegazio/status/1829529731320160675
const result = [];
const running = { interval: null };
const $column = document.querySelector('[data-testid="primaryColumn"]');
function scrap() {
const $user = $column.querySelector('[data-testid="cellInnerDiv"]');
if (!$user && running.interval) {
clearInterval(running.interval);
const filename = `users-${Date.now()}.txt`;
const text = result.join('\n\n');
const a = document.createElement('a');
const href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text);
a.setAttribute('href', href);
a.setAttribute('download', filename);
a.click();
a.remove();
}
const content = $user.innerText;
!result.includes(content) && result.push(content);
$user.remove();
}
running.interval = setInterval(scrap, 200);
@filipechagas
Copy link
Author

Make sure to read the authors own post about this nice experiment.

Nice one @felippe-regazio

@felippe-regazio
Copy link

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment