Created
July 11, 2012 19:40
-
-
Save stevederico/3092740 to your computer and use it in GitHub Desktop.
Screen-Scraper
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
Get the Bookmarklet here: javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g%3Ef.fn.jquery||h(f)){c=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d==%22loaded%22||d==%22complete%22)){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,%221.3.2%22,function($,L){var%20output%20=%20'First%20Name,Last%20Name,Email,Phone,Title,Company';var%20companies%20=%20$(%22.x-grid3-col-COMPANYNAME%22);var%20titles%20=%20$(%22.x-grid3-col-TITLE%22);var%20names%20=%20$(%22.GMUAMTYCBK%20%3E%20.GMUAMTYCFI%22);%20%20%20%20%20%20%20%20var%20i%20=%200;%20%20%20%20%20%20%20%20names.each(function(index,value)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20name%20=%20$(this).text();%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20partsOfStr%20=%20name.split(',');%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20lastName%20=%20partsOfStr[0];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20firstName%20=%20partsOfStr[1];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20phone%20=%20$(this).next().next().text();var%20email%20=%20$(this).next().text();var%20title%20=%20$(titles[i]).text().replace(%22in%20%22,%20%22%20in%20%22).replace(%22,%22,%22%22).replace(%22,%22,%22%22);var%20company%20=%20$(companies[i]).text().replace(%22,%22,%22%22).replace(%22%20Inc%20%22,%22%22).replace(%22%20Inc.%22,%22%22).replace(%22%20Inc%22,%22%22).replace(%22%20Co.%22,%22%22).replace(%22%20Ltd%22,%22%22).replace(%22%20Holdings%22,%22%22).replace(%22%20LLC%22,%22%22).replace(%22%20LTD%22,%22%22).replace(%22%20Corporation%22,%22%22).replace(%22%20Group%22,%22%22);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20personString%20=%20firstName%20+%20%22,%22%20+%20lastName%20+%20%22,%22%20+%20email%20+%20%22,%22%20+%20phone%20+%20%22,%22%20+%20title%20+%20%22,%22%20+%20company%20;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log%20(personString);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20output%20=%20output%20+%20%22\n%22%20+%20personString;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20i++;%20%20%20%20%20%20%20%20});%20%20%20%20%20%20%20%20%20console.log%20(output);%20%20%20%20%20%20%20%20%20%20window.prompt%20(%22Copy%20to%20clipboard:%20Ctrl+C,%20Enter%22,%20output);}); | |
function init(){ | |
var jq = document.createElement('script'); | |
jq.src = "http://code.jquery.com/jquery-latest.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
scrape(); | |
} | |
function scrape(){ | |
var output = 'First Name,Last Name,Email,Phone,Title,Company'; | |
var companies = $(".x-grid3-col-COMPANYNAME"); | |
var titles = $(".x-grid3-col-TITLE"); | |
var names = $(".GMUAMTYCBK > .GMUAMTYCFI"); | |
var i = 0; | |
names.each(function(index,value) { | |
var name = $(this).text(); | |
var partsOfStr = name.split(','); | |
var lastName = partsOfStr[0]; | |
var firstName = partsOfStr[1]; | |
var phone = $(this).next().next().text(); | |
var email = $(this).next().text(); | |
var title = $(titles[i]).text().replace("in ", " in ").replace(",","").replace(",",""); | |
var company = $(companies[i]).text().replace(",","").replace(" Inc ","").replace(" Inc.","").replace(" Inc","").replace(" Co.","").replace(" Ltd","").replace(" Holdings","").replace(" LLC","").replace(" LTD","").replace(" Corporation","").replace(" Group",""); | |
var personString = firstName + "," + lastName + "," + email + "," + phone + "," + title + "," + company ; | |
console.log (personString); | |
output = output + "\n" + personString; | |
i++; | |
}); | |
console.log (output); | |
window.prompt ("Copy to clipboard: Ctrl+C, Enter", output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment