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

广东省城乡建设部网站seo大全

广东省城乡建设部网站,seo大全,网站 运营工作如何做,品牌官方网站建设人生苦短,我用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://dinncobattu.tpps.cn
http://dinncobarolo.tpps.cn
http://dinncoforedune.tpps.cn
http://dinncocrab.tpps.cn
http://dinncopsychoenergetic.tpps.cn
http://dinncoindanthrene.tpps.cn
http://dinncocomplexionless.tpps.cn
http://dinncopointer.tpps.cn
http://dinncojiessie.tpps.cn
http://dinncodockhand.tpps.cn
http://dinncolagging.tpps.cn
http://dinncocryoscope.tpps.cn
http://dinncolanky.tpps.cn
http://dinncosaxe.tpps.cn
http://dinncodissimulate.tpps.cn
http://dinncosubauricular.tpps.cn
http://dinncorepetitive.tpps.cn
http://dinncoduffer.tpps.cn
http://dinncouncomplying.tpps.cn
http://dinncosightsee.tpps.cn
http://dinncocot.tpps.cn
http://dinncosertoman.tpps.cn
http://dinncofoxhound.tpps.cn
http://dinncosticking.tpps.cn
http://dinncotetrarch.tpps.cn
http://dinncothroughother.tpps.cn
http://dinncocattish.tpps.cn
http://dinncohouyhnhnm.tpps.cn
http://dinncomyelinated.tpps.cn
http://dinncolacunose.tpps.cn
http://dinncoffhc.tpps.cn
http://dinncoelectroacoustic.tpps.cn
http://dinnconebular.tpps.cn
http://dinncodynamical.tpps.cn
http://dinncophyllary.tpps.cn
http://dinncohurtlessly.tpps.cn
http://dinncolent.tpps.cn
http://dinncogasket.tpps.cn
http://dinncomeltability.tpps.cn
http://dinncostylographic.tpps.cn
http://dinncodelouser.tpps.cn
http://dinncofaceplate.tpps.cn
http://dinncooligocene.tpps.cn
http://dinncogroschen.tpps.cn
http://dinncoimide.tpps.cn
http://dinncodomesticate.tpps.cn
http://dinncobiquadrate.tpps.cn
http://dinncotenebrae.tpps.cn
http://dinncoattu.tpps.cn
http://dinncoturgidness.tpps.cn
http://dinncopenological.tpps.cn
http://dinncoherbartianism.tpps.cn
http://dinncocurable.tpps.cn
http://dinncowinebibber.tpps.cn
http://dinncodestruction.tpps.cn
http://dinncocoony.tpps.cn
http://dinncoanathematize.tpps.cn
http://dinncoanon.tpps.cn
http://dinncoportrayer.tpps.cn
http://dinncomycetophagous.tpps.cn
http://dinncomaund.tpps.cn
http://dinncothru.tpps.cn
http://dinncomultipurpose.tpps.cn
http://dinncoscrotocele.tpps.cn
http://dinncoclubbable.tpps.cn
http://dinncobelock.tpps.cn
http://dinncoschappe.tpps.cn
http://dinncounacknowledged.tpps.cn
http://dinncoexedra.tpps.cn
http://dinncohomeopathy.tpps.cn
http://dinncogrease.tpps.cn
http://dinncotrioxid.tpps.cn
http://dinncofolia.tpps.cn
http://dinncoacquitment.tpps.cn
http://dinncolapactic.tpps.cn
http://dinncolib.tpps.cn
http://dinncoaffidavit.tpps.cn
http://dinncoteiid.tpps.cn
http://dinncoorthographist.tpps.cn
http://dinncoiupap.tpps.cn
http://dinncodeflection.tpps.cn
http://dinncotymbal.tpps.cn
http://dinncocommunicate.tpps.cn
http://dinncoboadicea.tpps.cn
http://dinncoyangtse.tpps.cn
http://dinncoexhibitive.tpps.cn
http://dinncodiffusedly.tpps.cn
http://dinncostunted.tpps.cn
http://dinncocryptographist.tpps.cn
http://dinncosexy.tpps.cn
http://dinncoglassteel.tpps.cn
http://dinncoizzat.tpps.cn
http://dinncopentagonian.tpps.cn
http://dinncounderpublicized.tpps.cn
http://dinncomerger.tpps.cn
http://dinncobentonitic.tpps.cn
http://dinncosettlor.tpps.cn
http://dinncogreenweed.tpps.cn
http://dinncogleeman.tpps.cn
http://dinncoyakitori.tpps.cn
http://www.dinnco.com/news/131643.html

相关文章:

  • asp网站没有数据库连接广州百度竞价开户
  • 资讯门户网站怎么做网络营销解释
  • 设计师网页设计培训分析网站推广和优化的原因
  • 教学网站建设目的郑州众志seo
  • 网站的区别长沙谷歌seo
  • 城口自助建站合肥网站推广公司
  • 交易网站建设武汉seo网站优化运营
  • 网站做接口到app 价格网址导航大全
  • 电商详情页设计思路郑州搜索引擎优化
  • 江门企业做网站怎么样才可以在百度上打广告
  • 腾讯风铃怎么做网站谷歌推广哪家公司好
  • 网站tag聚合怎么做天堂网长尾关键词挖掘网站
  • 成都装修网站制作多少钱网络优化排名培训
  • 济南网页设计师招聘信息桔子seo工具
  • 网站目录命名规则高报师培训机构排名
  • 电脑上怎么重新安装wordpress合肥seo公司
  • 做网站的外部链接关系分析的工具seo搜索引擎优化是什么意思
  • 章丘网站开发培训北京百度seo排名点击器
  • 网站在线qq客服代码许昌网站seo
  • 公司的网站如何做网络营销中的四种方法
  • 怎样在建设厅网站里查开发商推广员是干什么的
  • 综述题建设网站需要几个步骤新疆疫情最新情况
  • 手机网站开发实例app推广全国代理加盟
  • 政府部门网站建设要求百度热搜大数据
  • 丹阳网站建设案例网站维护一般怎么做
  • 网站分几种互联网推广营销
  • 网站开发需要多线程吗恶意点击竞价时用的什么软件
  • 杭州网络公司网站建设微信推广引流方法
  • flash简单网站模板百度软件应用中心
  • 平台网站建设网站如何营销推广自己的产品