Skip to content

Instantly share code, notes, and snippets.

@ijharulislam
Created November 8, 2017 04:39
Show Gist options
  • Save ijharulislam/1f4a13bbac5200078155cfcb62812fd0 to your computer and use it in GitHub Desktop.
Save ijharulislam/1f4a13bbac5200078155cfcb62812fd0 to your computer and use it in GitHub Desktop.
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