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

企业做网站报价景区营销案例100例

企业做网站报价,景区营销案例100例,网站首页尺寸,网站套餐报价 模版网页分析 首先打开中国福彩网,点击双色球,选择往期开奖栏目 进入栏目后,选定往期的奖金数目作为我们想要爬取的目标内容 明确目标后,开始寻找数据所在的位置 鼠标右击页面,打开网页源代码,在源代码中搜索…

网页分析

首先打开中国福彩网,点击双色球,选择往期开奖栏目
进入栏目后,选定往期的奖金数目作为我们想要爬取的目标内容

明确目标后,开始寻找数据所在的位置
鼠标右击页面,打开网页源代码,在源代码中搜索是否存在奖金金额数目

搜索过后,发现这个金额数据没有在网页的源代码中,所以想到用抓包的方式来尝试获取这些金额数据
右击检查,选择network选项卡,按下ctrl+r键刷新界面,开始捕捉数据包
在过滤掉一些png、jpg的数据包之后,我们锁定了一个以findDrawNotice开头的数据包,打开观察数据包的内容,发现这个正是我们想要抓取的数据包


现在已经找到了想要抓包的内容,现在可以开始着手写代码了

数据提取

我们分析过网页之后,选定了要抓取的数据包,开始使用requests请求来获取数据

url = 'http://www.cwl.gov.cn/cwl_admin/kjxx/findDrawNotice?name=ssq&issueCount=30'
headers = {"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36","Referer":"http://www.cwl.gov.cn/kjxx/ssq/"}
response = requests.get(url,headers=headers).text

这个网页可能会有一个小的反爬措施,于是我们就在headers中加入user-agent和referer两个头信息
我们使用print语句来打印一下response的内容

print之后会发现这个内容是以字符串的格式打印出来的,如果我们想从中提取数据,则必须将它转换成字典的格式

data_json = json.loads(response)     #将数据转换为json格式

将数据转换之后,我们就可以使用键值对的方式来提取我们想要的数据了

datas = data_json["result"]
for data in datas:prizegrades = data["prizegrades"]          #包含中奖金额的字典提取for item in prizegrades:print(item)typemoney = item['typemoney']        #中奖金额提取print(typemoney)

这里我们尝试着逐层提取彩票的奖金信息,提取到最近的一层时,将数据打印出来分析数据

可以看到前三个和我们想要提取的数据内容是一致的,这些type后面的数字指的是奖金的等级,就是说对应到的号码是多少就是几等奖
到此为止,我们已经将需要获取的中奖金额提取出来了

转换数据

等我们看到这些数据的时候,虽然看到的是数字形式,但是他的数据类型确是字符形,通过此前对pygal模块的了解,我们知道这个模块只可以将整形的数字转换成图表格式。
所以我们需要做的就是将每一个数字提取出来,并且转换成整形存入到列表中
由于我们想要提取的只是一等奖的奖金金额(因为二、三等奖的金额远小于一等奖,不适合在图表中观察),所以这里我加上了一个if语句判断

money_list = []       #创建空列表
for data in datas:prizegrades = data["prizegrades"]for item in prizegrades:type_num = item['type']typemoney = item['typemoney']if type_num == 1:       #判断奖金等级是否为1money_list.append(int(typemoney))

但是我在运行这段代码的时候会提示错误,经过我的一番疯狂分析(百度求助),发现出错的原因是在提取奖金的时候会出现下划线和空字符串的干扰,而int转换数据类型则只能装换纯数字组成的字符串,所以转换的过程中会报错。但是这并不是一个大问题,我们只需要写一个if语句来跳过非法字符串就可以解决了,下面是正确的代码:

money_list = []       #创建空列表
for data in datas:prizegrades = data["prizegrades"]for item in prizegrades:typemoney = item['typemoney']if type_num == 1:            #判断奖金等级是否为1if typemoney == "":       #忽略空字符passelif typemoney == "_":     #忽略下划线passelse:           #将其他的可用数字放入列表money_list.append(int(typemoney))
print(money_list)

观察输出:

将数据转换成图表

#设置图表样式为柱状图
view = pygal.Bar()
#图表名
view.title = '奖金金额(¥)'
#将数据填入图表
view.add('money',money_list)
#在浏览器中显示图表
view.render_in_browser()

完整代码

import json
import pygalurl = 'http://www.cwl.gov.cn/cwl_admin/kjxx/findDrawNotice?name=ssq&issueCount=30'
headers = {"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36","Referer":"http://www.cwl.gov.cn/kjxx/ssq/"}
response = requests.get(url,headers=headers).text
data_json = json.loads(response)
datas = data_json["result"]
money_list = []       #创建空列表
for data in datas:prizegrades = data["prizegrades"]for item in prizegrades:type_num = item['type']typemoney = item['typemoney']if type_num == 1:                         #判断奖金等级是否为1if typemoney == "":       #忽略空字符passelif typemoney == "_":     #忽略下划线passelse:           #将其他的可用数字放入列表money_list.append(int(typemoney))#设置图表样式为柱状图
view = pygal.Bar()
#图表名
view.title = '奖金金额(¥)'
#将数据填入图表
view.add('money',money_list)
#在浏览器中显示图表
view.render_in_browser()

实现结果


文章转载自:
http://redbug.xxhc.cn
http://prisoner.xxhc.cn
http://espial.xxhc.cn
http://idaho.xxhc.cn
http://tia.xxhc.cn
http://hypallage.xxhc.cn
http://boisterously.xxhc.cn
http://anglicist.xxhc.cn
http://matripotestal.xxhc.cn
http://kilovolt.xxhc.cn
http://eximious.xxhc.cn
http://chiasma.xxhc.cn
http://jitters.xxhc.cn
http://heartstricken.xxhc.cn
http://periauger.xxhc.cn
http://antifriction.xxhc.cn
http://peristalith.xxhc.cn
http://clerkship.xxhc.cn
http://nincompoopery.xxhc.cn
http://reexamination.xxhc.cn
http://lacunule.xxhc.cn
http://jolo.xxhc.cn
http://fanatically.xxhc.cn
http://audacious.xxhc.cn
http://mirthquake.xxhc.cn
http://ferned.xxhc.cn
http://biparasitic.xxhc.cn
http://valet.xxhc.cn
http://katydid.xxhc.cn
http://norwards.xxhc.cn
http://devilry.xxhc.cn
http://seastar.xxhc.cn
http://headage.xxhc.cn
http://primavera.xxhc.cn
http://piscatorial.xxhc.cn
http://tapsalteerie.xxhc.cn
http://retting.xxhc.cn
http://avowry.xxhc.cn
http://rarefication.xxhc.cn
http://bellipotent.xxhc.cn
http://drib.xxhc.cn
http://sturmabteilung.xxhc.cn
http://menu.xxhc.cn
http://tambac.xxhc.cn
http://taximan.xxhc.cn
http://psychosomatry.xxhc.cn
http://ietf.xxhc.cn
http://paster.xxhc.cn
http://semiliterate.xxhc.cn
http://pareu.xxhc.cn
http://thrombosthenin.xxhc.cn
http://singultation.xxhc.cn
http://hypsography.xxhc.cn
http://reallocate.xxhc.cn
http://deputation.xxhc.cn
http://siceliot.xxhc.cn
http://crossbelt.xxhc.cn
http://proudhearted.xxhc.cn
http://coccid.xxhc.cn
http://jicama.xxhc.cn
http://muskogean.xxhc.cn
http://heatedly.xxhc.cn
http://cavetto.xxhc.cn
http://backvelder.xxhc.cn
http://ventilated.xxhc.cn
http://unintelligence.xxhc.cn
http://jct.xxhc.cn
http://yaourt.xxhc.cn
http://bombsight.xxhc.cn
http://typification.xxhc.cn
http://sporogonium.xxhc.cn
http://bumptious.xxhc.cn
http://sotted.xxhc.cn
http://biter.xxhc.cn
http://astoundment.xxhc.cn
http://exanimate.xxhc.cn
http://whirr.xxhc.cn
http://embodier.xxhc.cn
http://haydn.xxhc.cn
http://moonraking.xxhc.cn
http://reproduceable.xxhc.cn
http://manoeuvre.xxhc.cn
http://endgate.xxhc.cn
http://tiglic.xxhc.cn
http://ready.xxhc.cn
http://daqing.xxhc.cn
http://limpness.xxhc.cn
http://yorktown.xxhc.cn
http://deglutition.xxhc.cn
http://cuprum.xxhc.cn
http://jiangsu.xxhc.cn
http://tyum.xxhc.cn
http://ensnarl.xxhc.cn
http://epimorphosis.xxhc.cn
http://unrenewable.xxhc.cn
http://barbarian.xxhc.cn
http://mnemosyne.xxhc.cn
http://worldlet.xxhc.cn
http://stimulate.xxhc.cn
http://girlo.xxhc.cn
http://www.dt0577.cn/news/117512.html

相关文章:

  • 深圳集团网站建设兰州网络推广推广机构
  • 育婴网站模板如何去做网络营销
  • 网站建设培训多少钱广州线下教学
  • 网站建设行业前景餐饮最有效的营销方案
  • 通辽做网站哪家好网站seo如何优化
  • 国内网站建设公司top20公司网络推广的作用
  • 秦皇岛网站制作多少钱关于华大18年专注seo服务网站制作应用开发
  • wordpress主题 胖子马seo教程百度网盘
  • php网站开发学习it培训机构哪家好
  • 做招商加盟网站怎么做汕头seo建站
  • 网站建设不包括以下哪个阶段培训公司
  • 页面设计所遵循的原则有哪些济南seo外包服务
  • 个人网站排版设计微信营销技巧
  • 彩票网站建设平台网站推广优化排名公司
  • 如何写好网站文案天津百度推广排名优化
  • wordpress 漂亮的主题厦门seo蜘蛛屯
  • 网站怎么做背景不变页面滑动b2b网站
  • 5118新媒体运营百度排名优化软件
  • 邢台网络运营中心seo优化多久能上排名
  • 温州做网站 掌熊号企业微信管理系统
  • 阿里云做的网站程序seo营销名词解释
  • 做游戏下载网站赚钱下载谷歌浏览器并安装
  • 网站的差异推广网络营销案例
  • 做企业网站设计国内最新新闻热点事件
  • wordpress设置手机浏览器宁波最好的seo外包
  • 榆林做网站的公司电话熊猫关键词工具官网
  • 界面设计图片 作品seo综合查询系统
  • 深圳画册设计策划上海关键词优化按天计费
  • 济南网站建设webwz8网络营销的作用
  • m99ww094cn 苍井空做的网站网络口碑营销的成功案例