(function () {
var list = document.querySelectorAll("#shop-all-list>ul>li ");
var city = document.querySelector(".J-current-city").innerText;
var page = 0;
try {
page = document.querySelector(".page>a.cur").innerText;
} catch (err) {
console.log(err);
}
var region = "全市";
try {
region = document.querySelector("#region-nav>a.cur").getAttribute("data-click-title");
} catch (err) {
console.log(err);
}
var datas = '\uFEFF';
datas = datas + "code,name,address,city,region\r\n";
for (j = 0; j < list.length; j++) {
var div = list[j];
var d = div.querySelector(".operate.J_operate.Hide");
var a = d.querySelector("a.o-nearby.J_o-nearby");
var name = a.getAttribute("data-sname");
var address = "";//a.getAttribute("data-address");
var code = div.querySelector(".txt>.tit>a").getAttribute("href").replace("http://www.dianping.com/shop/", "");
var data = '"' + code + '","' + name + '","' + address + '","' + city + '","' + region + '"\r\n';
datas = datas + data;
}
var filename = city + "_" + region + "_" + page + ".csv";
var a = document.createElement('a');
var blob = new Blob([datas], {
type: "text/csv;charset=utf-8;"
});
a.download = filename;
a.href = URL.createObjectURL(blob);
a.click();
URL.revokeObjectURL(blob);
})();