Last active
December 9, 2020 11:03
-
-
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.
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
/* | |
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