Skip to content

Instantly share code, notes, and snippets.

@yurukov
Created April 5, 2016 14:05
Show Gist options
  • Save yurukov/173dc8f09e26c27e430b8c1ee9c56435 to your computer and use it in GitHub Desktop.
Save yurukov/173dc8f09e26c27e430b8c1ee9c56435 to your computer and use it in GitHub Desktop.
Scraper for all pharmacies in Bulgaria
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
data ="reg\tregCode\taddr1\tlead\taddr2";
task= setInterval(function() {
$("tr.highlight-row").each(function(i,a) {
var temp="";
$(a).find("td").each( function (i1,a1) {
temp+=$(a1).text()+"\t";
});
data+="\n"+temp.substring(0,temp.length-1);
});
if ($("a.pagination").last().text()!="Next") {
clearInterval(task);
download('apteki.tsv',data);
} else {
eval($("a.pagination").last().attr("href").substring(11))
}
},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment