整个设计的规划是先获取数据,然后算法推荐旅游的景点,最后就是搭建服务。
第一步,我们去获取天气信息,代码如下:
import requests
payload = {}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,**;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'max-age=0',
# 'If-Modified-Since': 'Mon, 18 Apr 2022 09:20:31 GMT',
# 'If-None-Match': '"fe38138d553d81:11e722"',
'Proxy-Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36',
}
response = requests.get(url), headers=headers, cookies=cookies,
verify=False)
对景点的html数据进行解析清理,数据展示如下:
数据现在都有了,我们需要根据sklearn算法对景点进行智能推荐。flask服务首页有搜索功能和推荐功能、热点城市等。等进入城市的详情页我们可以看见该城市对应的每个景点信息。整个设计的结果如下视频所示:
基于python景点天气及评价的信息采集系统设计和实现



