Skip to content

Instantly share code, notes, and snippets.

@yurukov

yurukov/scraper.js

Created Apr 5, 2016
Embed
What would you like to do?
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