当前位置: 首页 > news >正文

湖南省住房城乡建设网站wordpress插件水印

湖南省住房城乡建设网站,wordpress插件水印,南昌网站建设公务,网站前台设计工具由于篇幅限制#xff0c;无法展示完整代码#xff0c;需要的朋友可在下方获取#xff01;100%免费。 一、主题式网络爬虫设计方案 1. 主题式网络爬虫名称#xff1a;天气预报爬取数据与可视化数据 2. 主题式网络爬虫爬取的内容与数据特征分析#xff1a; - 爬取内容无法展示完整代码需要的朋友可在下方获取100%免费。 一、主题式网络爬虫设计方案 1. 主题式网络爬虫名称天气预报爬取数据与可视化数据 2. 主题式网络爬虫爬取的内容与数据特征分析 - 爬取内容天气预报网站上的历史天气数据 包括(日期最高温度最低温度天气风向等信息 - 数据特征分析时效性完整性结构化可预测性等特性 3. 主题式网络爬虫设计方案概述 -实现思路本次设计方案首先分析网站页面主要使用requests爬虫程序实现网页的请求、解析、过滤、存储等通过pandas库对数据进行分析和数据可视化处理。 -该过程遇到的难点动态加载、反爬虫、导致爬虫难以获取和解析数据数据可视化的效果和美观性 二、主题页面的结构特征分析 1主题页面的结构与特征分析 (1) 导航栏位于界面顶部 (2) 右侧热门城市历史天气 (3) 中间是内容区海口气温走势图以及风向统计 (4) 页面底部是网站信息和网站服务 2. Htmls 页面解析 classtianqi_pub_nav_box顶部导航栏 classtianqi_pub_nav_box右侧热门城市历史天气 内容区 页面底部 3. 节点标签查找方法与遍历方法 for循环迭代遍历 三、网络爬虫程序设计 数据来源:查看天气网http://www.tianqi.com.cn。访问海口市的历史天气网址https://lishi.tianqi.com/haikou/202311.html利用Python的爬虫技术从网站上爬取东莞市2023-11月历史天气数据信息。 Part1: 爬取天气网历海口史天气数据并保存未海口历史天气【2023年11月】.xls文件 1 import requests 2 from lxml import etree 3 import xlrd, xlwt, os 4 from xlutils.copy import copy 5 6 class TianQi(): 7 def \_\_init\_\_(self):8 pass9 10 #爬虫部分11 def spider(self): 12 city\_dict { 13 海口: haikou14 }15 city 海口16 city city\_dict\[f{city}\]17 year 202318 month 1119 start\_url fhttps://lishi.tianqi.com/{city}/{year}{month}.html20 headers { 21 authority: lishi.tianqi.com,22 accept: text/html,application/xhtmlxml,application/xml;q0.9,image/avif,image/webp,image/apng,\*/\*;q0.8,application/signed-exchange;vb3;q0.7,23 accept-language: zh-CN,zh;q0.9,24 cache-control: no-cache,25 # Requests sorts cookies alphabetically26 cookie: Hm\_lvt\_7c50c7060f1f743bccf8c150a646e90a1701184759; Hm\_lvt\_30606b57e40fddacb2c26d2b789efbcb1701184793; Hm\_lpvt\_30606b57e40fddacb2c26d2b789efbcb1701184932; Hm\_lpvt\_7c50c7060f1f743bccf8c150a646e90a1701185017,27 pragma: no-cache,28 referer: https://lishi.tianqi.com/ankang/202309.html,29 sec-ch-ua: Google Chrome;v119, Chromium;v119, Not?A\_Brand;v24,30 sec-ch-ua-mobile: ?0,31 sec-ch-ua-platform: Windows,32 sec-fetch-dest: document,33 sec-fetch-mode: navigate,34 sec-fetch-site: same-origin,35 sec-fetch-user: ?1,36 upgrade-insecure-requests: 1,37 user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36,38 }39 response requests.get(start\_url,headersheaders).text40 tree etree.HTML(response) 41 datas tree.xpath(/html/body/div\[classmain clearfix\]/div\[classmain\_left inleft\]/div\[classtian\_three\]/ul\[classthrui\]/li)42 weizhi 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 45 46 #解析部分47 def parase(self,datas,weizhi,year,month): 48 for data in datas: 49 #1、日期50 datetime data.xpath(./div\[classth200\]/text())\[0\]51 #2、最高气温52 max\_qiwen data.xpath(./div\[classth140\]\[1\]/text())\[0\]53 #3、最低气温54 min\_qiwen data.xpath(./div\[classth140\]\[2\]/text())\[0\]55 #4、天气56 tianqi data.xpath(./div\[classth140\]\[3\]/text())\[0\]57 #5、风向58 fengxiang data.xpath(./div\[classth140\]\[4\]/text())\[0\]59 dict\_tianqi { 60 日期:datetime,61 最高气温:max\_qiwen,62 最低气温:min\_qiwen,63 天气:tianqi,64 风向:fengxiang65 }66 data\_excel { 67 f{weizhi}【{year}年{month}月】:\[datetime,max\_qiwen,min\_qiwen,tianqi,fengxiang\]68 }69 self.chucun\_excel(data\_excel,weizhi,year,month)70 print(dict\_tianqi)71 72 73 #储存部分74 def chucun\_excel(self, data,weizhi,year,month): 75 if not os.path.exists(f{weizhi}【{year}年{month}月】.xls):76 # 1、创建 Excel 文件77 wb xlwt.Workbook(encodingutf-8)78 # 2、创建新的 Sheet 表79 sheet wb.add\_sheet(f{weizhi}【{year}年{month}月】, cell\_overwrite\_okTrue)80 # 3、设置 Borders边框样式81 borders xlwt.Borders() 82 borders.left xlwt.Borders.THIN 83 borders.right xlwt.Borders.THIN 84 borders.top xlwt.Borders.THIN 85 borders.bottom xlwt.Borders.THIN 86 borders.left\_colour 0x4087 borders.right\_colour 0x4088 borders.top\_colour 0x4089 borders.bottom\_colour 0x4090 style xlwt.XFStyle() # Create Style91 style.borders borders # Add Borders to Style92 # 4、写入时居中设置93 align xlwt.Alignment() 94 align.horz 0x02 # 水平居中95 align.vert 0x01 # 垂直居中96 style.alignment align 97 # 5、设置表头信息, 遍历写入数据 保存数据98 header ( 99 日期, 最高气温, 最低气温, 天气, 风向) 100 for i in range(0, len(header)): 101 sheet.col(i).width 2560 \* 3 102 #行列 内容 样式 103 sheet.write(0, i, header\[i\], style) 104 wb.save(f{weizhi}【{year}年{month}月】.xls) 105 # 判断工作表是否存在 106 if os.path.exists(f{weizhi}【{year}年{month}月】.xls): 107 # 打开工作薄 108 wb xlrd.open\_workbook(f{weizhi}【{year}年{month}月】.xls) 109 # 获取工作薄中所有表的个数 110 sheets wb.sheet\_names() 111 for i in range(len(sheets)): 112 for name in data.keys(): 113 worksheet wb.sheet\_by\_name(sheets\[i\]) 114 # 获取工作薄中所有表中的表名与数据名对比 115 if worksheet.name name: 116 # 获取表中已存在的行数 117 rows\_old worksheet.nrows 118 # 将xlrd对象拷贝转化为xlwt对象 119 new\_workbook copy(wb) 120 # 获取转化后的工作薄中的第i张表 121 new\_worksheet new\_workbook.get\_sheet(i) 122 for num in range(0, len(data\[name\])): 123 new\_worksheet.write(rows\_old, num, data\[name\]\[num\]) 124 new\_workbook.save(f{weizhi}【{year}年{month}月】.xls) 125 126 if \_\_name\_\_ \_\_main\_\_: 127 tTianQi() 128 t.spider() Part2:根据海口历史天气【2023年11月】.xls生成海口市天气分布图 1 import pandas as pd 2 from pyecharts.charts import Pie 3 from pyecharts import options as opts 4 from pyecharts.globals import ThemeType 5 6 def on(gender\_counts): 7 total gender\_counts.sum() 8 percentages {gender: count / total \* 100 for gender, count in gender\_counts.items()} 9 analysis\_parts \[\] 10 for gender, percentage in percentages.items(): 11 analysis\_parts.append(f{gender}天气占比为{percentage:.2f}%) 12 analysis\_report 天气比例饼状图显示 .join(analysis\_parts) 13 return analysis\_report 14 15 df pd.read\_excel(海口历史天气【2023年11月】.xls) 16 gender\_counts df\[天气\].value\_counts() 17 analysis\_text on(gender\_counts) 18 pie Pie(init\_optsopts.InitOpts(themeThemeType.WESTEROS,bg\_color#e4cf8e)) 19 20 pie.add( 21 series\_name海口市天气分布, 22 data\_pair\[list(z) for z in zip(gender\_counts.index.tolist(), gender\_counts.values.tolist())\], 23 radius\[40%, 70%\], 24 rosetyperadius, 25 label\_optsopts.LabelOpts(is\_showTrue, positionoutside, font\_size14, 26 formatter{a}br/{b}: {c} ({d}%)) 27 ) 28 pie.set\_global\_opts( 29 title\_optsopts.TitleOpts(title海口市11月份天气分布,pos\_right50%), 30 legend\_optsopts.LegendOpts(orientvertical, pos\_top15%, pos\_left2%), 31 toolbox\_optsopts.ToolboxOpts(is\_showTrue) 32 ) 33 pie.set\_series\_opts(label\_optsopts.LabelOpts(formatter{b}: {c} ({d}%))) 34 html\_content pie.render\_embed() 35 36 # 生成HTML文件 37 complete\_html f 38 html 39 head 40 title天气数据分析/title 41 42 /head 43 body stylebackground-color: #e87f7f 44 div stylemargin-top: 20px;background-color#e87f7f 45 div{html\_content}/div 46 h3分析报告/h3 47 p{analysis\_text}/p 48 /div 49 /body 50 /html 51 52 # 保存到HTML文件 53 with open(海口历史天气【2023年11月】饼图可视化.html, w, encodingutf-8) as file: 54 file.write(complete\_html) Part3:根据海口历史天气【2023年11月】.xls生成海口市温度趋势 1 import pandas as pd 2 import matplotlib.pyplot as plt 3 from matplotlib import font\_manager 4 import jieba 5 6 # 中文字体7 font\_CN font\_manager.FontProperties(fnameC:\\Windows\\Fonts\\STKAITI.TTF)8 9 # 读取数据 10 df pd.read\_excel(海口历史天气【2023年11月】.xls) 11 12 # 使用 jieba 处理数据去除 C 13 df\[最高气温\] df\[最高气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 14 df\[最低气温\] df\[最低气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 15 # 开始绘图 16 plt.figure(figsize(20, 8), dpi80) 17 max\_tp df\[最高气温\].tolist() 18 min\_tp df\[最低气温\].tolist() 19 x\_day range(1, 31) 20 # 绘制30天最高气温 21 plt.plot(x\_day, max\_tp, label 最高气温, color red) 22 # 绘制30天最低气温 23 plt.plot(x\_day, min\_tp, label 最低气温, color skyblue) 24 # 增加x轴刻度 25 \_xtick\_label \[11月{}日.format(i) for i in x\_day\] 26 plt.xticks(x\_day, \_xtick\_label, fontpropertiesfont\_CN, rotation45) 27 # 添加标题 28 plt.title(2023年11月最高气温与最低气温趋势, fontpropertiesfont\_CN) 29 plt.xlabel(日期, fontpropertiesfont\_CN) 30 plt.ylabel(温度单位°C, fontpropertiesfont\_CN) 31 plt.legend(prop font\_CN) 32 plt.show() Part4:根据海口历史天气【2023年11月】.xls生成海口市词汇图 1 from pyecharts.charts import WordCloud 2 from pyecharts import options as opts 3 from pyecharts.globals import SymbolType 4 import jieba 5 import pandas as pd 6 from collections import Counter 7 8 # 读取Excel文件9 df pd.read\_excel(海口历史天气【2023年11月】.xls) 10 # 提取商品名 11 word\_names df\[风向\].tolist() df\[天气\].tolist() 12 # 提取关键字 13 seg\_list \[jieba.lcut(text) for text in word\_names\] 14 words \[word for seg in seg\_list for word in seg if len(word) 1\] 15 word\_counts Counter(words) 16 word\_cloud\_data \[(word, count) for word, count in word\_counts.items()\] 17 18 # 创建词云图 19 wordcloud ( 20 WordCloud(init\_optsopts.InitOpts(bg\_color#00FFFF)) 21 .add(, word\_cloud\_data, word\_size\_range\[20, 100\], shapeSymbolType.DIAMOND, 22 word\_gap5, rotate\_step45, 23 textstyle\_optsopts.TextStyleOpts(font\_familycursive, font\_size15)) 24 .set\_global\_opts(title\_optsopts.TitleOpts(title天气预报词云图,pos\_top5%, pos\_leftcenter), 25 toolbox\_optsopts.ToolboxOpts( 26 is\_showTrue, 27 feature{ 28 saveAsImage: {}, 29 dataView: {}, 30 restore: {}, 31 refresh: {} 32 } 33 ) 34 35 ) 36 ) 37 38 # 渲染词图到HTML文件 39 wordcloud.render(天气预报词云图.html) 爬虫课程设计全部代码如下: 1 import requests2 from lxml import etree3 import xlrd, xlwt, os4 from xlutils.copy import copy5 6 class TianQi():7 def \_\_init\_\_(self):8 pass9 10 #爬虫部分11 def spider(self):12 city\_dict {13 海口: haikou14 }15 city 海口16 city city\_dict\[f{city}\]17 year 202318 month 1119 start\_url fhttps://lishi.tianqi.com/{city}/{year}{month}.html20 headers {21 authority: lishi.tianqi.com,22 accept: text/html,application/xhtmlxml,application/xml;q0.9,image/avif,image/webp,image/apng,\*/\*;q0.8,application/signed-exchange;vb3;q0.7,23 accept-language: zh-CN,zh;q0.9,24 cache-control: no-cache,25 # Requests sorts cookies alphabetically26 cookie: Hm\_lvt\_7c50c7060f1f743bccf8c150a646e90a1701184759; Hm\_lvt\_30606b57e40fddacb2c26d2b789efbcb1701184793; Hm\_lpvt\_30606b57e40fddacb2c26d2b789efbcb1701184932; Hm\_lpvt\_7c50c7060f1f743bccf8c150a646e90a1701185017,27 pragma: no-cache,28 referer: https://lishi.tianqi.com/ankang/202309.html,29 sec-ch-ua: Google Chrome;v119, Chromium;v119, Not?A\_Brand;v24,30 sec-ch-ua-mobile: ?0,31 sec-ch-ua-platform: Windows,32 sec-fetch-dest: document,33 sec-fetch-mode: navigate,34 sec-fetch-site: same-origin,35 sec-fetch-user: ?1,36 upgrade-insecure-requests: 1,37 user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36,38 }39 response requests.get(start\_url,headersheaders).text40 tree etree.HTML(response)41 datas tree.xpath(/html/body/div\[classmain clearfix\]/div\[classmain\_left inleft\]/div\[classtian\_three\]/ul\[classthrui\]/li)42 weizhi 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 45 46 #解析部分47 def parase(self,datas,weizhi,year,month):48 for data in datas:49 #1、日期50 datetime data.xpath(./div\[classth200\]/text())\[0\]51 #2、最高气温52 max\_qiwen data.xpath(./div\[classth140\]\[1\]/text())\[0\]53 #3、最低气温54 min\_qiwen data.xpath(./div\[classth140\]\[2\]/text())\[0\]55 #4、天气56 tianqi data.xpath(./div\[classth140\]\[3\]/text())\[0\]57 #5、风向58 fengxiang data.xpath(./div\[classth140\]\[4\]/text())\[0\]59 dict\_tianqi {60 日期:datetime,61 最高气温:max\_qiwen,62 最低气温:min\_qiwen,63 天气:tianqi,64 风向:fengxiang65 }66 data\_excel {67 f{weizhi}【{year}年{month}月】:\[datetime,max\_qiwen,min\_qiwen,tianqi,fengxiang\]68 }69 self.chucun\_excel(data\_excel,weizhi,year,month)70 print(dict\_tianqi)71 72 73 #储存部分74 def chucun\_excel(self, data,weizhi,year,month):75 if not os.path.exists(f{weizhi}【{year}年{month}月】.xls):76 # 1、创建 Excel 文件77 wb xlwt.Workbook(encodingutf-8)78 # 2、创建新的 Sheet 表79 sheet wb.add\_sheet(f{weizhi}【{year}年{month}月】, cell\_overwrite\_okTrue)80 # 3、设置 Borders边框样式81 borders xlwt.Borders()82 borders.left xlwt.Borders.THIN83 borders.right xlwt.Borders.THIN84 borders.top xlwt.Borders.THIN85 borders.bottom xlwt.Borders.THIN86 borders.left\_colour 0x4087 borders.right\_colour 0x4088 borders.top\_colour 0x4089 borders.bottom\_colour 0x4090 style xlwt.XFStyle() # Create Style91 style.borders borders # Add Borders to Style92 # 4、写入时居中设置93 align xlwt.Alignment()94 align.horz 0x02 # 水平居中95 align.vert 0x01 # 垂直居中96 style.alignment align97 # 5、设置表头信息, 遍历写入数据 保存数据98 header (99 日期, 最高气温, 最低气温, 天气, 风向) 100 for i in range(0, len(header)): 101 sheet.col(i).width 2560 \* 3 102 # 行列 内容 样式 103 sheet.write(0, i, header\[i\], style) 104 wb.save(f{weizhi}【{year}年{month}月】.xls) 105 # 判断工作表是否存在 106 if os.path.exists(f{weizhi}【{year}年{month}月】.xls): 107 # 打开工作薄 108 wb xlrd.open\_workbook(f{weizhi}【{year}年{month}月】.xls) 109 # 获取工作薄中所有表的个数 110 sheets wb.sheet\_names() 111 for i in range(len(sheets)): 112 for name in data.keys(): 113 worksheet wb.sheet\_by\_name(sheets\[i\]) 114 # 获取工作薄中所有表中的表名与数据名对比 115 if worksheet.name name: 116 # 获取表中已存在的行数 117 rows\_old worksheet.nrows 118 # 将xlrd对象拷贝转化为xlwt对象 119 new\_workbook copy(wb) 120 # 获取转化后的工作薄中的第i张表 121 new\_worksheet new\_workbook.get\_sheet(i) 122 for num in range(0, len(data\[name\])): 123 new\_worksheet.write(rows\_old, num, data\[name\]\[num\]) 124 new\_workbook.save(f{weizhi}【{year}年{month}月】.xls) 125 126 if \_\_name\_\_ \_\_main\_\_: 127 tTianQi() 128 t.spider() 129 import pandas as pd 130 import jieba 131 from pyecharts.charts import Scatter 132 from pyecharts import options as opts 133 134 from scipy import stats 135 136 # 读取数据 137 df pd.read\_excel(海口历史天气【2023年11月】.xls) 138 139 # 使用 jieba 处理数据去除 C 140 df\[最高气温\] df\[最高气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 141 df\[最低气温\] df\[最低气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 142 143 # 创建散点图 144 scatter Scatter() 145 scatter.add\_xaxis(df\[最低气温\].tolist()) 146 scatter.add\_yaxis(最高气温, df\[最高气温\].tolist()) 147 scatter.set\_global\_opts(title\_optsopts.TitleOpts(title最低气温与最高气温的散点图)) 148 html\_content scatter.render\_embed() 149 150 # 计算回归方程 151 slope, intercept, r\_value, p\_value, std\_err stats.linregress(df\[最低气温\], df\[最高气温\]) 152 153 print(f回归方程为y {slope}x {intercept}) 154 155 analysis\_text f回归方程为y {slope}x {intercept} 156 # 生成HTML文件 157 complete\_html f 158 html 159 head 160 title天气数据分析/title 161 /head 162 body stylebackground-color: #e87f7f 163 div stylemargin-top: 20px;background-color#e87f7f 164 div{html\_content}/div 165 p{analysis\_text}/p 166 /div 167 /body 168 /html 169 170 # 保存到HTML文件 171 with open(海口历史天气【2023年11月】散点可视化.html, w, encodingutf-8) as file: 172 file.write(complete\_html) 173 174 import pandas as pd 175 from flatbuffers.builder import np 176 from matplotlib import pyplot as plt 177 from pyecharts.charts import Pie 178 from pyecharts import options as opts 179 from pyecharts.globals import ThemeType 180 181 def on(gender\_counts): 182 total gender\_counts.sum() 183 percentages {gender: count / total \* 100 for gender, count in gender\_counts.items()} 184 analysis\_parts \[\] 185 for gender, percentage in percentages.items(): 186 analysis\_parts.append(f{gender}天气占比为{percentage:.2f}%) 187 analysis\_report 天气比例饼状图显示 .join(analysis\_parts) 188 return analysis\_report 189 190 df pd.read\_excel(海口历史天气【2023年11月】.xls) 191 gender\_counts df\[天气\].value\_counts() 192 analysis\_text on(gender\_counts) 193 pie Pie(init\_optsopts.InitOpts(themeThemeType.WESTEROS,bg\_color#e4cf8e)) 194 pie.add( 195 series\_name海口市天气分布, 196 data\_pair\[list(z) for z in zip(gender\_counts.index.tolist(), gender\_counts.values.tolist())\], 197 radius\[40%, 70%\], 198 rosetyperadius, 199 label\_optsopts.LabelOpts(is\_showTrue, positionoutside, font\_size14, 200 formatter{a}br/{b}: {c} ({d}%)) 201 ) 202 pie.set\_global\_opts( 203 title\_optsopts.TitleOpts(title海口市11月份天气分布,pos\_right50%), 204 legend\_optsopts.LegendOpts(orientvertical, pos\_top15%, pos\_left2%), 205 toolbox\_optsopts.ToolboxOpts(is\_showTrue) 206 ) 207 pie.set\_series\_opts(label\_optsopts.LabelOpts(formatter{b}: {c} ({d}%))) 208 html\_content pie.render\_embed() 209 210 # 生成HTML文件 211 complete\_html f 212 html 213 head 214 title天气数据分析/title 215 216 /head 217 body stylebackground-color: #e87f7f 218 div stylemargin-top: 20px;background-color#e87f7f 219 div{html\_content}/div 220 h3分析报告/h3 221 p{analysis\_text}/p 222 /div 223 /body 224 /html 225 226 227 import pandas as pd 228 import matplotlib.pyplot as plt 229 from matplotlib import font\_manager 230 import jieba 231 232 # 中文字体 233 font\_CN font\_manager.FontProperties(fnameC:\\Windows\\Fonts\\STKAITI.TTF) 234 235 # 读取数据 236 df pd.read\_excel(海口历史天气【2023年11月】.xls) 237 238 # 使用 jieba 处理数据去除 C 239 df\[最高气温\] df\[最高气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 240 df\[最低气温\] df\[最低气温\].apply(lambda x: .join(jieba.cut(x))).str.replace(℃, ).astype(float) 241 # 开始绘图 242 plt.figure(figsize(20, 8), dpi80) 243 max\_tp df\[最高气温\].tolist() 244 min\_tp df\[最低气温\].tolist() 245 x\_day range(1, 31) 246 # 绘制30天最高气温 247 plt.plot(x\_day, max\_tp, label 最高气温, color red) 248 # 绘制30天最低气温 249 plt.plot(x\_day, min\_tp, label 最低气温, color skyblue) 250 # 增加x轴刻度 251 \_xtick\_label \[11月{}日.format(i) for i in x\_day\] 252 plt.xticks(x\_day, \_xtick\_label, fontpropertiesfont\_CN, rotation45) 253 # 添加标题 254 plt.title(2023年11月最高气温与最低气温趋势, fontpropertiesfont\_CN) 255 plt.xlabel(日期, fontpropertiesfont\_CN) 256 plt.ylabel(温度单位°C, fontpropertiesfont\_CN) 257 plt.legend(prop font\_CN) 258 plt.show() 259 260 from pyecharts.charts import WordCloud 261 from pyecharts import options as opts 262 from pyecharts.globals import SymbolType 263 import jieba 264 import pandas as pd 265 from collections import Counter 266 267 # 读取Excel文件 268 df pd.read\_excel(海口历史天气【2023年11月】.xls) 269 # 提取商品名 270 word\_names df\[风向\].tolist() df\[天气\].tolist() 271 # 提取关键字 272 seg\_list \[jieba.lcut(text) for text in word\_names\] 273 words \[word for seg in seg\_list for word in seg if len(word) 1\] 274 word\_counts Counter(words) 275 word\_cloud\_data \[(word, count) for word, count in word\_counts.items()\] 276 277 # 创建词云图 278 wordcloud ( 279 WordCloud(init\_optsopts.InitOpts(bg\_color#00FFFF)) 280 .add(, word\_cloud\_data, word\_size\_range\[20, 100\], shapeSymbolType.DIAMOND, 281 word\_gap5, rotate\_step45, 282 textstyle\_optsopts.TextStyleOpts(font\_familycursive, font\_size15)) 283 .set\_global\_opts(title\_optsopts.TitleOpts(title天气预报词云图,pos\_top5%, pos\_leftcenter), 284 toolbox\_optsopts.ToolboxOpts( 285 is\_showTrue, 286 feature{ 287 saveAsImage: {}, 288 dataView: {}, 289 restore: {}, 290 refresh: {} 291 } 292 ) 293 294 ) 295 ) 296 297 # 渲染词图到HTML文件 298 wordcloud.render(天气预报词云图.html) 四、总结 1.根据散点图的显示回归方y 0.6988742964352719x 10.877423389618516来获取海口市11月份温度趋势 2.根据饼状图可以了解海口市11月份的天气比例多云天气占比为53.33%晴天气占比为26.67%阴天气占比为13.33%小雨天气占比为6.67% 3.根据折线图了解海口市11月份的最高温度和最低温度趋势。 4.根据词云图的显示可以了解当月的天气质量相关内容。 _综述是通过Python爬虫技术获取天气预报数据_数据爬取方面通过Python编写爬虫程序利用网络爬虫技术从天气网站上获取天气预报数据并进行数据清洗和处理。_数据可视化方面利用数据可视化工具将存储的数据进行可视化展示以便用户更直观地了解天气情况_因此用户更好地理解和应用天气数据从而做出更准确的决策和规划。 由于篇幅限制无法展示完整代码需要的朋友可在下方获取100%免费。
http://www.hkea.cn/news/14567309/

相关文章:

  • 做企业网站需要资质吗打造爆品营销方案
  • 梅兰商贸网站开发设计苏州市建设局老网站
  • 网站里添加图片超链接怎么做甘肃肃第八建设集团网站1
  • 泰州网站制作企业wordpress系列教程 pdf
  • app介绍类网站模板工作准备区域的组成包括
  • 网站开发怎么学游戏开发网站开发
  • 放单网站做外贸一般做什么
  • 大连网站制作中企动力最有前景的代理产品
  • 合肥高端网站建设费用园林公司网站建设费用
  • 网站建设三站合一网站做微信支付宝支付
  • jsp淘宝客网站网吧服务员
  • 做印刷的网站官网排名优化方案
  • 一个网站可以设多少关键词住房公积金个人提取
  • 网站开发界面设计用什么工具深圳哪家网站建设好seo1888
  • 手机网站宽度自适应澧县住房和城乡建设局网站
  • 电子商务推广网站富阳网站建设公司
  • 公章电子版在线制作网站网站设计名称
  • 360网站收录提交入口大全销售管理系统下载
  • 外贸工艺品网站建设昌都市网站建设
  • 网站注销流程外贸网站友情链接
  • 银川建设网站公司邮箱如何注册企业邮箱
  • linux做网站1G内存够不陕西省交通建设集团公司门户网站
  • 重庆网站建设找重庆万为电子商务网站建设期末作业
  • 遵义网站建设价格贵阳好的网站建设
  • 做汽车网站销售怎么入手网站建设与开发考试
  • 用网页制作个人网站外贸平台有哪些
  • 电商网站开发常用代码微信营销策略有哪些
  • 网站建设教程特别棒湖南岚鸿权 威黑帽seo教程
  • php网站建设模板重庆沙坪坝企业网站建设联系电话
  • 新泰营销型网站建设沧州礼品行业网站设计