欢迎大家点赞、收藏、关注、评论啦 ,由于篇幅有限,只展示了部分核心代码。
一项目简介
随着我国旅游业的不断发展,名宿作为一种新型而具有特色的接待形式,通过温馨而亲民的方式为游客提供了更加具有地方特色的旅游体验。本项目利用网络爬虫技术从去哪儿网采集名宿酒店数据,并进行数据清洗和格式化,利用 flask 搭建后台,前端利用 echarts 等实现对名宿酒店的各类属性分布进行可视化分析。
二、数据读取
功能主要包括:
三、基于 Python 的高考志愿高校及专业分析系统
3.1 登录注册
3.2 名宿酒店名称关键词抽取并词云分析
3.3 不同档次名宿数量分布情况
3.4 不同区域名宿酒店数量分布情况
四. 名宿酒店信息爬虫
利用python 执行 curl 命令,抓取某旅游平台的名宿酒店住宿数据:
total_count = 0
total_hotels = []
for cmd in curl_cmds:
cmd = cmd.replace('\\', '')
resp = os.popen(cmd)
resp = resp.read()
resp = json.loads(resp)
hotels = resp['data']['hotels']
for hotel in hotels:
hotel_info = {
"name": hotel['name'],
"price": hotel['price'],
"roomType": hotel['roomType'],
"score": hotel['score'],
"locationInfo": hotel['locationInfo'],
"imageid": hotel['imageid'],
"etag": hotel['etag'] if 'etag' in hotel else '暂无',
"dangciText": hotel['dangciText'],
"commentDesc": hotel['commentDesc'] if 'commentDesc' in hotel else '好',
"commentCount": hotel['commentCount'],
}
total_hotels.append(hotel_info)
total_count += len(hotels)
# 保存数据
with open('hotel_info.json', 'w', encoding='utf8') as fout:
fout.writelines([json.dumps(line, ensure_ascii=False) + '\n' for line in total_hotels])
五. 总结
随着我国旅游业的不断发展,名宿作为一种新型而具有特色的接待形式,通过温馨而亲民的方式为游客提供了更加具有地方特色的旅游体验。本项目利用网络爬虫技术从去哪儿网采集名宿酒店数据,并进行数据清洗和格式化,利用 flask 搭建后台,前端利用 echarts 等实现对名宿酒店的各类属性分布进行可视化分析。