温馨提示:文末有 CSDN 平台官方提供的学长 QQ 名片 :)
随着我国旅游业的不断发展,名宿作为一种新型而具有特色的接待形式,通过温馨而亲民的方式为游客提供了更加具有地方特色的旅游体验。本项目利用网络爬虫技术从去哪儿网采集名宿酒店数据,并进行数据清洗和格式化,利用 flask 搭建后台,前端利用 echarts 等实现对名宿酒店的各类属性分布进行可视化分析。
基于python的民宿旅馆消费数据分析系统的功能主要包括:

利用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])

4.3 不同档次名宿数量分布情况
4.5 不同地区名宿房源数与平均价格的分布情况
4.7 北京地区名宿酒店单价最高Top20


随着我国旅游业的不断发展,名宿作为一种新型而具有特色的接待形式,通过温馨而亲民的方式为游客提供了更加具有地方特色的旅游体验。本项目利用网络爬虫技术从去哪儿网采集名宿酒店数据,并进行数据清洗和格式化,利用 flask 搭建后台,前端利用 echarts 等实现对名宿酒店的各类属性分布进行可视化分析。
欢迎大家点赞、收藏、关注、评论啦 ,由于篇幅有限,只展示了部分核心代码。
技术交流认准下方 CSDN 官方提供的学长 QQ 名片 :)
精彩专栏推荐订阅:
