爬去去哪儿门票,并且可视化分析价格和销量的关系
2017-12-23 22:52
344 查看
url=r'http://piao.qunar.com/ticket/list.htm?keyword=%s®ion=&from=mps_search_suggest&page=%d&sort=pp'%(encode_kw,i)
res=request.urlopen(url)
str_html=res.read().decode('utf8')
html=BeautifulSoup(str_html)
items=html.find_all('div',{'class':'sight_item_detail clrfix'})
for item in items:
name=item.find_all('h3',{'class':'sight_item_caption'})[0].string
img=item.find_all('img',{'class':'img_opacity load'})[0]
img=img['data-original']
price=item.find_all('span',{'class':'sight_item_price'})[0]
price=price.em.string
sales=item.find_all('span',{'class':'hot_num'})[0].string
address=item.find_all('p',{'class':'address color999'})[0]
address=address.span.string
tmp={'price':price,
'sales':sales,
'name':name,
'address':address,
'img':img}
data.append(tmp)
for i in range(len(data)):
li_prices.append(data[i]['price'])
li_sales.append(data[i]['sales'])
#li_names.append(data[i]['name'])
x.append(i)
line=Line('sales and prices')
line.add('sales',x,li_sales,xaxis_interval=0)
line.add('prices',x,li_prices,xaxis_interval=0)
line.render()
res=request.urlopen(url)
str_html=res.read().decode('utf8')
html=BeautifulSoup(str_html)
items=html.find_all('div',{'class':'sight_item_detail clrfix'})
for item in items:
name=item.find_all('h3',{'class':'sight_item_caption'})[0].string
img=item.find_all('img',{'class':'img_opacity load'})[0]
img=img['data-original']
price=item.find_all('span',{'class':'sight_item_price'})[0]
price=price.em.string
sales=item.find_all('span',{'class':'hot_num'})[0].string
address=item.find_all('p',{'class':'address color999'})[0]
address=address.span.string
tmp={'price':price,
'sales':sales,
'name':name,
'address':address,
'img':img}
data.append(tmp)
for i in range(len(data)):
li_prices.append(data[i]['price'])
li_sales.append(data[i]['sales'])
#li_names.append(data[i]['name'])
x.append(i)
line=Line('sales and prices')
line.add('sales',x,li_sales,xaxis_interval=0)
line.add('prices',x,li_prices,xaxis_interval=0)
line.render()
相关文章推荐
- 使用matplotlib.pyplot + xlrd + pandas使租房价格面积数据关系可视化
- 关系分析可视化插件-Cytoscape
- 携程&去哪儿移动端产品分析报告
- 分析函数调用关系图(call graph)的几种方法
- 源码分析Handler 、 Looper 、Message之间的关系
- 数据可视化分析工具大集合
- V4L2 soc-camera 分析 - 调用关系
- 天池体验(二)——新人离线赛数据可视化分析
- 软件工程个人小程序:分析一个文本文件(英文文章)中各个词出现的频率,并且把频率最高的10个词打印出来
- android分析windowManager、window、viewGroup之间关系(一)
- 精确分析复杂的递推关系(nlogn算法的初始条件)
- 时序大数据可视化分析平台研究与设计
- 网元关系设计和分析引擎
- C/C++中二维数组和指针关系分析
- 利用python进行数据分析(六):绘图和可视化
- 分析奇数与偶数之间的关系
- 内核proc文件系统与seq接口(6)----分析sysctl函数接口与procfs之间的内部关系
- 基于caffe与MATLAB接口的回归分析与可视化
- 1.大数据工具简单分析天猫年底月销量
- 数据可视化之文本情绪(极性)分析