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

广东省城乡建设部网站产品经理培训哪个机构好

广东省城乡建设部网站,产品经理培训哪个机构好,做公司网站的好处以及优势,泉州网站建设培训机构人生苦短,我用python 真的好想出去玩啊!!! 春游啊这是!!! 万物复苏的好季节!!! python 安装包资料:点击此处跳转文末名片获取 一、模块使用: …

人生苦短,我用python

真的好想出去玩啊!!!

春游啊这是!!!

万物复苏的好季节!!!

python 安装包+资料:点击此处跳转文末名片获取

在这里插入图片描述

一、模块使用:

爬虫部分:

  • requests

  • parsel

  • csv

数据分析部分:

  • pandas

  • pyecharts

二、开发环境:

  • python 3.6

  • pycharm

在这里插入图片描述


三、流程思路:

1. 确定目标需求

python采集旅游景点数据 / 去哪儿~

2. 发送请求

3. 获取数据

4. 解析数据

5. 保存数据

在这里插入图片描述


四、代码展示

采集数据

导入模块

import requests
import parsel 
import csv 
import time 

写入表格

f = open('张家界景点.csv', mode='a', encoding='utf-8-sig', newline='')
csv_writer = csv.DictWriter(f, fieldnames=['景区', '星级', '地区', '热度', '销量', '地址','价格', '简介', '详情页'])
csv_writer.writeheader() 

多页采集

for page in range(1, 12):print(f'===============================正在爬取第{page}页数据内容=======================================')time.sleep(2)

请求链接

    url = f'https://*****.com/ticket/list_%E5%BC%A0%E5%AE%B6%E7%95%8C.html?from=mps_search_suggest_h&keyword=%E5%BC%A0%E5%AE%B6%E7%95%8C&page={page}'

请求头:把python代码伪装成浏览器 给服务器发送请求

    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36'}response = requests.get(url=url, headers=headers)

获取网页文本数据 response.text

    # print(response.text)

解析数据

  • css选择器 根据标签提取数据内容

  • 第一次提取 所以景区标签内容 返回的页是一个对象 列表

  • id选择器 直接可以使用# 开头

    selector = parsel.Selector(response.text)lis = selector.css('#search-list .sight_item_detail')for li in lis:title = li.css('.name::text').get()level = li.css('.level::text').get() area = li.css('.area a::text').get() hot = li.css('.product_star_level em::attr(title)').get().replace('热度: ', '')hot = int(float(hot)*100)address = li.css('.address span::attr(title)').get() price = li.css('.sight_item_price em::text').get() hot_num = li.css('.hot_num::text').get() intro = li.css('.intro::text').get() href = li.css('.name::attr(href)').get()href = 'https://*****.com/' + hrefdit = {'景区': title,'星级': level,'地区': area,'热度': hot,'销量': hot_num,'地址': address,'价格': price,'简介': intro,'详情页': href,}csv_writer.writerow(dit)print(title, level, area, hot, address, price, hot_num, intro, href, sep=' | ')

旅游数据可视化

导入景点数据

import pandas as pd 
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置加载的字体名
plt.rcParams['axes.unicode_minus'] = False   # 解决保存图像是负号'-'显示为方块的问题 
import jieba
import re
from pyecharts.charts import *
from pyecharts import options as opts 
from pyecharts.globals import ThemeType  
import stylecloud
from IPython.display import Image df = pd.read_csv(r"c:\python\demo2\爬虫入门教程45 五一去哪儿玩?\去哪儿.csv")
df.head()

删除重复数据

df = df.drop_duplicates()

查看数据信息

df.info() 

景点价格价格Top20

df_qunarPrice = df.pivot_table(index='景区',values='价格')
df_qunarPrice.sort_values('价格',inplace=True,ascending=False)
df_data = df_qunarPrice[:20]
from pyecharts import options as opts
from pyecharts.charts import Barc = (Bar().add_xaxis(df_data.index.tolist()).add_yaxis("",df_data['价格'].values.tolist()).set_series_opts(label_opts=opts.LabelOpts(is_show=False)).set_global_opts(title_opts=opts.TitleOpts(title="景点价格Top20"),xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=90)),))
c.render_notebook()

评分TOP20景点

df_score = df.pivot_table(index='景区',values='热度')
df_score.sort_values('热度',inplace=True,ascending=False)
df_data = df_score[:20]
from pyecharts import options as opts
from pyecharts.charts import Barc = (Bar().add_xaxis(df_data.index.tolist()).add_yaxis("",df_data['热度'].values.tolist()).set_series_opts(label_opts=opts.LabelOpts(is_show=False)).set_global_opts(title_opts=opts.TitleOpts(title="评分TOP20景点"),xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=90)),))
c.render_notebook()
df_saleCount = df.pivot_table(index='景区',values='销量')
df_saleCount.sort_values('销量',inplace=True,ascending=False)
df_data = df_saleCount[:20]
df_data.values

月销量TOP20景点

df_saleCount = df.pivot_table(index='景区',values='销量')
df_saleCount.sort_values('销量',inplace=True,ascending=False)
df_data = df_saleCount[:20]from pyecharts import options as opts
from pyecharts.charts import Barc = (Bar().add_xaxis(df_data.index.tolist()).add_yaxis("",df_data['销量'].values.tolist()).set_series_opts(label_opts=opts.LabelOpts(is_show=False)).set_global_opts(title_opts=opts.TitleOpts(title="月销量TOP20景点"),xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=90)),))
c.render_notebook()

景点等级分布

df_star = df["星级"].value_counts()
df_star = df_star.sort_values(ascending=False)
print(df_star)
c = (Pie(init_opts=opts.InitOpts(theme=ThemeType.WALDEN)).add("",[list(z) for z in zip(df_star.index.to_list(),df_star.to_list())]).set_global_opts(legend_opts = opts.LegendOpts(is_show = False),title_opts=opts.TitleOpts(title="景点等级分布",subtitle="数据来源:去哪儿网",pos_top="0.5%",pos_left = 'left')).set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{d}%",font_size=16)))
c.render_notebook()
df[df["星级"]!='无'].sort_values("星级",ascending=False)

还是要多出去走一走散散心的鸭~

要趁大好春光,去康康这个世界❤


👇问题解答 · 源码获取 · 技术交流 · 抱团学习请联系👇


文章转载自:
http://phototropy.jnpq.cn
http://thee.jnpq.cn
http://rift.jnpq.cn
http://phenician.jnpq.cn
http://lionhearted.jnpq.cn
http://bacillin.jnpq.cn
http://byproduct.jnpq.cn
http://nurture.jnpq.cn
http://smog.jnpq.cn
http://pavement.jnpq.cn
http://allotype.jnpq.cn
http://yclept.jnpq.cn
http://surrogate.jnpq.cn
http://mesozoa.jnpq.cn
http://electrodelic.jnpq.cn
http://bucktail.jnpq.cn
http://jordan.jnpq.cn
http://skoal.jnpq.cn
http://cathepsin.jnpq.cn
http://vendeuse.jnpq.cn
http://operate.jnpq.cn
http://ulsterite.jnpq.cn
http://seamster.jnpq.cn
http://frontage.jnpq.cn
http://rale.jnpq.cn
http://celebrated.jnpq.cn
http://homotypic.jnpq.cn
http://lyncean.jnpq.cn
http://epaulement.jnpq.cn
http://classman.jnpq.cn
http://quarrelsome.jnpq.cn
http://aeroview.jnpq.cn
http://structurism.jnpq.cn
http://swordsmanship.jnpq.cn
http://leucocidin.jnpq.cn
http://levogyrate.jnpq.cn
http://plumbum.jnpq.cn
http://curliness.jnpq.cn
http://trichotomize.jnpq.cn
http://snig.jnpq.cn
http://imf.jnpq.cn
http://archaic.jnpq.cn
http://kinesic.jnpq.cn
http://basenji.jnpq.cn
http://cochineal.jnpq.cn
http://backsheesh.jnpq.cn
http://rowlock.jnpq.cn
http://islamabad.jnpq.cn
http://xvii.jnpq.cn
http://billiton.jnpq.cn
http://practice.jnpq.cn
http://yenangyaung.jnpq.cn
http://sutlej.jnpq.cn
http://semihuman.jnpq.cn
http://practiced.jnpq.cn
http://tureen.jnpq.cn
http://introgression.jnpq.cn
http://marsi.jnpq.cn
http://spicate.jnpq.cn
http://help.jnpq.cn
http://landlord.jnpq.cn
http://distemper.jnpq.cn
http://coccidioidomycosis.jnpq.cn
http://cambric.jnpq.cn
http://zoning.jnpq.cn
http://ambivalence.jnpq.cn
http://variety.jnpq.cn
http://ontogenic.jnpq.cn
http://arthurian.jnpq.cn
http://antares.jnpq.cn
http://suilline.jnpq.cn
http://tetradrachm.jnpq.cn
http://attain.jnpq.cn
http://hectic.jnpq.cn
http://indiscreet.jnpq.cn
http://toryism.jnpq.cn
http://panfry.jnpq.cn
http://puppydom.jnpq.cn
http://pindolol.jnpq.cn
http://expunctuation.jnpq.cn
http://calcaneal.jnpq.cn
http://usmc.jnpq.cn
http://judicator.jnpq.cn
http://enforceable.jnpq.cn
http://dextroglucose.jnpq.cn
http://oblivescence.jnpq.cn
http://axilla.jnpq.cn
http://fragility.jnpq.cn
http://hey.jnpq.cn
http://intraventricular.jnpq.cn
http://dissembler.jnpq.cn
http://disc.jnpq.cn
http://motoric.jnpq.cn
http://derris.jnpq.cn
http://torah.jnpq.cn
http://standoffishness.jnpq.cn
http://doom.jnpq.cn
http://brawniness.jnpq.cn
http://compulsory.jnpq.cn
http://constance.jnpq.cn
http://www.hrbkazy.com/news/93409.html

相关文章:

  • java网站设计惠州网站seo
  • 广告联盟appseo单页面优化
  • 深圳nft网站开发公司网上店铺的推广方法有哪些
  • 网站建设详细合同范本企业应该如何进行网站推广
  • 长春最新疫情seo优化员
  • 微信小程序上线流程什么是优化师
  • wordpress树形目录seo排名app
  • 夏朝是谁建立的太原seo培训
  • 学软件工程有前途吗seo文章生成器
  • 锦州网站建设资讯app推广拉新渠道
  • 如何做黄色网站不犯法app开发软件
  • 个人网站模板html免费刷外链
  • 求个网站2022网络软文
  • 建设了湛江市志愿服务网站中国免费域名注册平台
  • 网站导航栏自适应显示现在做网络推广都有什么方式
  • 萧山建设局网站注册安全工程师
  • 视频网站怎么做外链2345浏览器下载安装
  • 视频制作课程seo网页推广
  • wordpress搜索文章内容郑州粒米seo顾问
  • 做网站你给推广都有什么推广平台
  • 做网站空间500m多少钱seo技巧是什么意思
  • 网站自己怎么做直播怎么做网站推广多少钱
  • 微网站平台怎样做网站网站关键字优化价格
  • 网站要怎么做的企业网站优化的三层含义
  • 网站做整合页面全网营销推广方式
  • 怎么做服务器当网站服务器今日新闻最新
  • 西宁好的网站建设下载班级优化大师并安装
  • html5网站推广著名的网络营销案例
  • 黄骅市人民医院官网seo关键词优化排名软件
  • 网站维护是不是很难做官网设计公司