爬取大众点评-各大城市的医疗美容板块数据
2021/10/23 23:41:00
本文主要是介绍爬取大众点评-各大城市的医疗美容板块数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
(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); })();
这篇关于爬取大众点评-各大城市的医疗美容板块数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-15JavaMailSender是什么,怎么使用?-icode9专业技术文章分享
- 2024-11-15JWT 用户校验学习:从入门到实践
- 2024-11-15Nest学习:新手入门全面指南
- 2024-11-15RestfulAPI学习:新手入门指南
- 2024-11-15Server Component学习:入门教程与实践指南
- 2024-11-15动态路由入门:新手必读指南
- 2024-11-15JWT 用户校验入门:轻松掌握JWT认证基础
- 2024-11-15Nest后端开发入门指南
- 2024-11-15Nest后端开发入门教程
- 2024-11-15RestfulAPI入门:新手快速上手指南