Last active
December 1, 2022 10:10
-
-
Save pradyumnac/21c21fe9218c6dd9200f04c9a79c7353 to your computer and use it in GitHub Desktop.
Get Twitter Followers by url scrapping( Chrome Console / pypeteer / Selenium )
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
// Run this link on https://twitter.com/<username>/following | |
// On a Twitter "Following" timeline, run this in console | |
// You can trigger thuis through chrome console as well | |
async function getAllFollowers() { | |
window.scrollTo(0,0); | |
var hs = new Set(); | |
var last_hs_size; | |
var ctr=0; | |
const getFollowers=function (){ | |
last_hs_size = hs.size; | |
var rawtext=document.querySelector("div[aria-label='Timeline: Following']").textContent; | |
const regex=/@\w*?Follow/ig; | |
rawtext.match(regex).forEach(el=>hs.add(el.replace("@","").replace("Follow",""),'')); | |
// console.log(hs.size, last_hs_size) | |
if (hs.size==last_hs_size) { return false; } else {return true;} | |
} | |
var new_followers_fetched = true | |
while(new_followers_fetched) { | |
window.scrollTo(0, 2000*ctr); | |
await new Promise(r => setTimeout(r, 2000)); | |
new_followers_fetched = getFollowers(); | |
console.log("th loop") | |
ctr = ctr+1; | |
}; | |
console.log(hs.size+" Fetched"); | |
return Array.from(hs).join(","); // csv | |
// return "http://localhost:8000/"+Array.from(hs).join("?count=25\nhttp://localhost:8000/")+"?count25"; //newsboat twitter proxy list | |
} | |
var followers = await getAllFollowers(); | |
console.log(followers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment