Last active
September 5, 2024 18:33
-
-
Save filipechagas/f8ca247b0e4096bd83ca97aa16c06638 to your computer and use it in GitHub Desktop.
Twitter Followers Inspector-Scrapping
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
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure to read the authors own post about this nice experiment.
Nice one @felippe-regazio