Created
November 8, 2017 04:39
-
-
Save ijharulislam/1f4a13bbac5200078155cfcb62812fd0 to your computer and use it in GitHub Desktop.
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
var data = $.csv.toObjects(data); | |
console.log(data) | |
var i = 0; | |
function ScrapeLocation(){ | |
if (data[i].Location){ | |
var q = data[i].Params + "+" + data[i].Location; | |
} else { | |
var q = data[i].Params + "+" + data[0].Location; | |
} | |
var q = q.replace(' ', '+').replace('++', '+').replace(' ','+') | |
var url = 'https://www.google.com/search?q=' + q; | |
$.ajax(url) | |
.done(function(response) { | |
var html = new DOMParser().parseFromString(response, "text/html"); | |
var link = html.getElementById('lu_map'); | |
if(link){ | |
var result = { | |
"Search Param": q.replace('+', ' '), | |
"Google Link": url | |
} | |
// console.log(result); | |
locations.push(result); | |
} | |
updateProgressbar(data.length, i); | |
if(data.length == i){ | |
ExportCSV(locations); | |
alert("Exporting successfully completed!"); | |
} | |
if(i<data.length){ | |
setTimeout(ScrapeLocation, 500); | |
} | |
i ++; | |
}) | |
} | |
ScrapeLocation(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment