Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamtalhaasghar/7f80330116889961e5b6c8153cb5561a to your computer and use it in GitHub Desktop.
Save iamtalhaasghar/7f80330116889961e5b6c8153cb5561a to your computer and use it in GitHub Desktop.
A simple javascript code snippet to scrap emails from a Google Forms Page (View other Responses Page). Just open up the Google Form in a new tab. Go to Console, paste the code and boom!!! ProTip: Copy the console log to clipboard and then paste the clipboard contents to a newly created .txt file. You will have your required data in a nice format.
/*
It only scraps first 100 emails because other emails are not visible.
Whenever I will have time, i will try to work around this problem
Tested on Firefox 80.0.1
Not sure about other browsers, (theoretically it should work)
*/
// xpath of div containing emails in a google form
allDivs = $x("//*[contains(text(),'Email') and @class='freebirdAnalyticsViewQuestionTitle']/ancestor::div[@class='freebirdAnalyticsViewAnalyticsHover']")
// get innerText which is essentially emails of all correspondents and also contains some other irrelevant text
uglyData = allDivs[0].innerText.split('\n')
// clean data and append all emails to a string variable and print it in console
emails = ''
for(i = 0; i<uglyData.length; i++){
if(uglyData[i].indexOf('@') != -1)
emails += uglyData[i].toLowerCase() + "\n"
}
// enjoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment