爬虫抓取c5game饰品交易数据
2017-12-04 23:37
1111 查看
本来想今天接着复习计算机网络的,结果晚饭后看到有人写抓取steam的数据,然后、、、手就痒痒起来。最近正好在igxe和c5game上倒卖饰品,平时一个个点开,真的巨麻烦
简单的写了下csgo的,只爬取了c5game的饰品的名称,最低价,周销量以及总销量,顺便把steam上该饰品的市场url也抓了出来
下面便是代码:
运行结果:
2017-12-06更
好像正则表达式写的很low,重新改了下,顺便把c5game上给出的steam预测价也抓了出来,比对c5game售价和steam预测价,差价狠狠赚一波
import urllib2
import re
p=re.compile(r'''<p class="name">\s+<a href="(.+?)"><span class=" text-unique ">(.+?)</span></a>\s+</p>\s+<p class="info">\s+<span class="pull-left">\s+.+<span class="price">¥(.+?)</span> .+\s+</span>\s+<span class="num">\s+(.+)\s+</span>''')
q=re.compile(r'''<div class="hero">\s+<span>Reference: .+\( about ¥ (.+?) \)</span>''')
for i in range(10):
target=('https://www.c5game.com/csgo/default/result.html?locale=zh&page=%d') %i
url1=urllib2.urlopen(target)
result_csgo_menu=url1.read()
match_csgo_menu=p.findall(result_csgo_menu)
for row in match_csgo_menu:
address=row[0]
name=row[1]
c5game_price=float(row[2])
count=row[3]
c5game_address='https://www.c5game.com/'+address
url_c5game_thing=urllib2.urlopen(c5game_address)
result_c5game_thing=url_c5game_thing.read()
match_thing=q.findall(result_c5game_thing)
predict_price=float(match_thing[0])
print '%s\t%s' %(name,count)
print 'c5最低价:%f\t\tsteam预测价:%f' %(c5game_price,predict_price)
不过好像c5给出的预测价不太准,我尝试抓了一下steam市场的数据,发现货币种类不同,我只能够抓取我大天朝玩家出售的饰品,而天朝玩家饰品占的总数不算太多,差不多1/5,好像没什么参考性,等以后研究出怎么统一货币再更新一下
简单的写了下csgo的,只爬取了c5game的饰品的名称,最低价,周销量以及总销量,顺便把steam上该饰品的市场url也抓了出来
下面便是代码:
# -*- coding: utf-8 -*- """ Created on Mon Dec 04 22:38:17 2017 @author: dala_da """ import urllib2 import re p=re.compile(r'''<p class="name"> <a href="(.+?)"><span class=" text-unique ">(.+?)</span></a> </p> <p class="info"> <span class="pull-left"> .+<span class="price">¥(.+?)</span> .+ </span> <span class="num"> (.+) </span>''') for i in range(10): target=('https://www.c5game.com/csgo/default/result.html?locale=zh&page=%d') %i url1=urllib2.urlopen(target) result_csgo_menu=url1.read() match_csgo_menu=p.findall(result_csgo_menu) for row in match_csgo_menu: address=row[0] name=row[1] c5game_price=row[2] count=row[3] print name, c5game_price,count
运行结果:
2017-12-06更
好像正则表达式写的很low,重新改了下,顺便把c5game上给出的steam预测价也抓了出来,比对c5game售价和steam预测价,差价狠狠赚一波
import urllib2
import re
p=re.compile(r'''<p class="name">\s+<a href="(.+?)"><span class=" text-unique ">(.+?)</span></a>\s+</p>\s+<p class="info">\s+<span class="pull-left">\s+.+<span class="price">¥(.+?)</span> .+\s+</span>\s+<span class="num">\s+(.+)\s+</span>''')
q=re.compile(r'''<div class="hero">\s+<span>Reference: .+\( about ¥ (.+?) \)</span>''')
for i in range(10):
target=('https://www.c5game.com/csgo/default/result.html?locale=zh&page=%d') %i
url1=urllib2.urlopen(target)
result_csgo_menu=url1.read()
match_csgo_menu=p.findall(result_csgo_menu)
for row in match_csgo_menu:
address=row[0]
name=row[1]
c5game_price=float(row[2])
count=row[3]
c5game_address='https://www.c5game.com/'+address
url_c5game_thing=urllib2.urlopen(c5game_address)
result_c5game_thing=url_c5game_thing.read()
match_thing=q.findall(result_c5game_thing)
predict_price=float(match_thing[0])
print '%s\t%s' %(name,count)
print 'c5最低价:%f\t\tsteam预测价:%f' %(c5game_price,predict_price)
不过好像c5给出的预测价不太准,我尝试抓了一下steam市场的数据,发现货币种类不同,我只能够抓取我大天朝玩家出售的饰品,而天朝玩家饰品占的总数不算太多,差不多1/5,好像没什么参考性,等以后研究出怎么统一货币再更新一下
相关文章推荐
- mysql中kill掉所有锁表的进程爬虫抓取数据分析
- [python和大数据-1]利用爬虫登录知乎进行BFS搜索抓取用户信息本地mysql分析【PART1】
- 知乎爬虫之4:抓取页面数据
- 分布式爬虫:使用Scrapy抓取数据
- Pyhton爬虫实战 - 抓取BOSS直聘职位描述 和 数据清洗
- 爬虫怎么去除抓取数据中的'\xa0\xa0\xa0\xa'
- 爬虫抓取糯米网上所有商家数据
- python&php数据抓取、爬虫分析与中介,有网址案例
- 使用爬虫抓取网站异步加载数据
- python 爬虫 实战(一) —— 抓取学校开课数据
- QQ空间爬虫分享(一天可抓取400万条数据)
- python写爬虫2-数据抓取的三种方式
- 爬虫抓取暗黑3国服天梯榜数据及分析
- Pyhton爬虫实战 - 抓取BOSS直聘职位描述 和 数据清洗
- node.js 小爬虫抓取网页数据(2)
- Nodejs实现爬虫抓取数据实例解析
- 抓取网贷之家的数据爬虫
- 新浪微博爬虫分享(一天可抓取 1300 万条数据)
- 爬虫小程序(实习僧网抓取数据)
- Python爬虫抓取手机APP的传输数据