96SEO 2026-02-20 03:08 0
-实现思路本次设计方案首先分析网站页面主要使用requests爬虫程序实现网页的请求、解析、过滤、存储等通过pandas库对数据进行分析和数据可视化处理。

-该过程遇到的难点动态加载、反爬虫、导致爬虫难以获取和解析数据数据可视化的效果和美观性
classtianqi_pub_nav_box右侧热门城市历史天气
数据来源:查看天气网http://www.tianqi.com.cn。
访问海口市的历史天气网址https://lishi.tianqi.com/haikou/202311.html利用Python的爬虫技术从网站上爬取东莞市2023-11月历史天气数据信息。
爬取天气网历海口史天气数据并保存未海口历史天气【2023年11月】.xls文件
fhttps://lishi.tianqi.com/{city}/{year}{month}.html20
text/html,application/xhtmlxml,application/xml;q0.9,image/avif,image/webp,image/apng,\*/\*;q0.8,application/signed-exchange;vb3;q0.7,23
Hm\_lvt\_7c50c7060f1f743bccf8c150a646e90a1701184759;
Hm\_lvt\_30606b57e40fddacb2c26d2b789efbcb1701184793;
Hm\_lpvt\_30606b57e40fddacb2c26d2b789efbcb1701184932;
Hm\_lpvt\_7c50c7060f1f743bccf8c150a646e90a1701185017,27
https://lishi.tianqi.com/ankang/202309.html,29
requests.get(start\_url,headersheaders).text40
tree.xpath(/html/body/div\[classmain
clearfix\]/div\[classmain\_left
inleft\]/div\[classtian\_three\]/ul\[classthrui\]/li)42
tree.xpath(/html/body/div\[classmain
clearfix\]/div\[classmain\_left
inleft\]/div\[classinleft\_tian\]/div\[classtian\_one\]/div\[classflex\]\[1\]/h3/text())\[0\]43
self.parase(datas,weizhi,year,month)44
parase(self,datas,weizhi,year,month):
data.xpath(./div\[classth200\]/text())\[0\]51
data.xpath(./div\[classth140\]\[1\]/text())\[0\]53
data.xpath(./div\[classth140\]\[2\]/text())\[0\]55
data.xpath(./div\[classth140\]\[3\]/text())\[0\]57
data.xpath(./div\[classth140\]\[4\]/text())\[0\]59
f{weizhi}【{year}年{month}月】:\[datetime,max\_qiwen,min\_qiwen,tianqi,fengxiang\]68
self.chucun\_excel(data\_excel,weizhi,year,month)70
os.path.exists(f{weizhi}【{year}年{month}月】.xls):76
wb.add\_sheet(f{weizhi}【{year}年{month}月】,
wb.save(f{weizhi}【{year}年{month}月】.xls)
os.path.exists(f{weizhi}【{year}年{month}月】.xls):
xlrd.open\_workbook(f{weizhi}【{year}年{month}月】.xls)
wb.sheet\_by\_name(sheets\[i\])
new\_worksheet.write(rows\_old,
new\_workbook.save(f{weizhi}【{year}年{month}月】.xls)
Part2:根据海口历史天气【2023年11月】.xls生成海口市天气分布图
analysis\_parts.append(f{gender}天气占比为{percentage:.2f}%)
pd.read\_excel(海口历史天气【2023年11月】.xls)
Pie(init\_optsopts.InitOpts(themeThemeType.WESTEROS,bg\_color#e4cf8e))
zip(gender\_counts.index.tolist(),
gender\_counts.values.tolist())\],
label\_optsopts.LabelOpts(is\_showTrue,
title\_optsopts.TitleOpts(title海口市11月份天气分布,pos\_right50%),
legend\_optsopts.LegendOpts(orientvertical,
toolbox\_optsopts.ToolboxOpts(is\_showTrue)
pie.set\_series\_opts(label\_optsopts.LabelOpts(formatter{b}:
open(海口历史天气【2023年11月】饼图可视化.html,
Part3:根据海口历史天气【2023年11月】.xls生成海口市温度趋势
font\_manager.FontProperties(fnameC:\\Windows\\Fonts\\STKAITI.TTF)8
pd.read\_excel(海口历史天气【2023年11月】.xls)
.join(jieba.cut(x))).str.replace(℃,
.join(jieba.cut(x))).str.replace(℃,
Part4:根据海口历史天气【2023年11月】.xls生成海口市词汇图
pd.read\_excel(海口历史天气【2023年11月】.xls)
WordCloud(init\_optsopts.InitOpts(bg\_color#00FFFF))
textstyle\_optsopts.TextStyleOpts(font\_familycursive,
.set\_global\_opts(title\_optsopts.TitleOpts(title天气预报词云图,pos\_top5%,
fhttps://lishi.tianqi.com/{city}/{year}{month}.html20
text/html,application/xhtmlxml,application/xml;q0.9,image/avif,image/webp,image/apng,\*/\*;q0.8,application/signed-exchange;vb3;q0.7,23
Hm\_lvt\_7c50c7060f1f743bccf8c150a646e90a1701184759;
Hm\_lvt\_30606b57e40fddacb2c26d2b789efbcb1701184793;
Hm\_lpvt\_30606b57e40fddacb2c26d2b789efbcb1701184932;
Hm\_lpvt\_7c50c7060f1f743bccf8c150a646e90a1701185017,27
https://lishi.tianqi.com/ankang/202309.html,29
requests.get(start\_url,headersheaders).text40
tree.xpath(/html/body/div\[classmain
clearfix\]/div\[classmain\_left
inleft\]/div\[classtian\_three\]/ul\[classthrui\]/li)42
tree.xpath(/html/body/div\[classmain
clearfix\]/div\[classmain\_left
inleft\]/div\[classinleft\_tian\]/div\[classtian\_one\]/div\[classflex\]\[1\]/h3/text())\[0\]43
self.parase(datas,weizhi,year,month)44
parase(self,datas,weizhi,year,month):48
data.xpath(./div\[classth200\]/text())\[0\]51
data.xpath(./div\[classth140\]\[1\]/text())\[0\]53
data.xpath(./div\[classth140\]\[2\]/text())\[0\]55
data.xpath(./div\[classth140\]\[3\]/text())\[0\]57
data.xpath(./div\[classth140\]\[4\]/text())\[0\]59
f{weizhi}【{year}年{month}月】:\[datetime,max\_qiwen,min\_qiwen,tianqi,fengxiang\]68
self.chucun\_excel(data\_excel,weizhi,year,month)70
os.path.exists(f{weizhi}【{year}年{month}月】.xls):76
wb.add\_sheet(f{weizhi}【{year}年{month}月】,
wb.save(f{weizhi}【{year}年{month}月】.xls)
os.path.exists(f{weizhi}【{year}年{month}月】.xls):
xlrd.open\_workbook(f{weizhi}【{year}年{month}月】.xls)
wb.sheet\_by\_name(sheets\[i\])
new\_worksheet.write(rows\_old,
new\_workbook.save(f{weizhi}【{year}年{month}月】.xls)
pd.read\_excel(海口历史天气【2023年11月】.xls)
.join(jieba.cut(x))).str.replace(℃,
.join(jieba.cut(x))).str.replace(℃,
scatter.add\_xaxis(df\[最低气温\].tolist())
scatter.set\_global\_opts(title\_optsopts.TitleOpts(title最低气温与最高气温的散点图))
open(海口历史天气【2023年11月】散点可视化.html,
analysis\_parts.append(f{gender}天气占比为{percentage:.2f}%)
pd.read\_excel(海口历史天气【2023年11月】.xls)
Pie(init\_optsopts.InitOpts(themeThemeType.WESTEROS,bg\_color#e4cf8e))
zip(gender\_counts.index.tolist(),
gender\_counts.values.tolist())\],
label\_optsopts.LabelOpts(is\_showTrue,
title\_optsopts.TitleOpts(title海口市11月份天气分布,pos\_right50%),
legend\_optsopts.LegendOpts(orientvertical,
toolbox\_optsopts.ToolboxOpts(is\_showTrue)
pie.set\_series\_opts(label\_optsopts.LabelOpts(formatter{b}:
font\_manager.FontProperties(fnameC:\\Windows\\Fonts\\STKAITI.TTF)
pd.read\_excel(海口历史天气【2023年11月】.xls)
.join(jieba.cut(x))).str.replace(℃,
.join(jieba.cut(x))).str.replace(℃,
pd.read\_excel(海口历史天气【2023年11月】.xls)
WordCloud(init\_optsopts.InitOpts(bg\_color#00FFFF))
textstyle\_optsopts.TextStyleOpts(font\_familycursive,
.set\_global\_opts(title\_optsopts.TitleOpts(title天气预报词云图,pos\_top5%,
10.877423389618516来获取海口市11月份温度趋势
2.根据饼状图可以了解海口市11月份的天气比例多云天气占比为53.33%晴天气占比为26.67%阴天气占比为13.33%小雨天气占比为6.67%
_综述是通过Python爬虫技术获取天气预报数据_数据爬取方面通过Python编写爬虫程序利用网络爬虫技术从天气网站上获取天气预报数据并进行数据清洗和处理。
_数据可视化方面利用数据可视化工具将存储的数据进行可视化展示以便用户更直观地了解天气情况_因此用户更好地理解和应用天气数据从而做出更准确的决策和规划。
由于篇幅限制无法展示完整代码需要的朋友可在下方获取100%免费。
作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。
| 服务项目 | 基础套餐 | 标准套餐 | 高级定制 |
|---|---|---|---|
| 关键词优化数量 | 10-20个核心词 | 30-50个核心词+长尾词 | 80-150个全方位覆盖 |
| 内容优化 | 基础页面优化 | 全站内容优化+每月5篇原创 | 个性化内容策略+每月15篇原创 |
| 技术SEO | 基本技术检查 | 全面技术优化+移动适配 | 深度技术重构+性能优化 |
| 外链建设 | 每月5-10条 | 每月20-30条高质量外链 | 每月50+条多渠道外链 |
| 数据报告 | 月度基础报告 | 双周详细报告+分析 | 每周深度报告+策略调整 |
| 效果保障 | 3-6个月见效 | 2-4个月见效 | 1-3个月快速见效 |
我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:
全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。
基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。
解决网站技术问题,优化网站结构,提升页面速度和移动端体验。
创作高质量原创内容,优化现有页面,建立内容更新机制。
获取高质量外部链接,建立品牌在线影响力,提升网站权威度。
持续监控排名、流量和转化数据,根据效果调整优化策略。
基于我们服务的客户数据统计,平均优化效果如下:
我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。
Demand feedback