python抓取京东价格分析京东商品价格走势
from creepy import Crawler
from BeautifulSoup import BeautifulSoup
import urllib2
import jsonclass MyCrawler(Crawler):
def process_document(self, doc):
if doc.status == 200:
print '[%d] %s' % (doc.status, doc.url)
try:
soup = BeautifulSoup(doc.text.decode('gb18030').encode('utf-8'))
except Exception as e:
print e
soup = BeautifulSoup(doc.text)
print soup.find(id="product-intro").div.h1.text
url_id=urllib2.unquote(doc.url).decode('utf8').split('/')[-1].split('.')[0]
f = urllib2.urlopen('http://p.3.cn/prices/get?skuid=J_'+url_id,timeout=5)
price=json.loads(f.read())
f.close()
print price[0]['p']
else:
passcrawler = MyCrawler()
crawler.set_follow_mode(Crawler.F_SAME_HOST)
crawler.set_concurrency_level(16)
crawler.add_url_filter('\.(jpg|jpeg|gif|png|js|css|swf)$')
crawler.crawl('http://item.jd.com/982040.html')
您可能感兴趣的文章:
- python抓取京东价格分析京东商品价格走势
- Python爬虫(一)京东商品价格及详情页抓取
- python 抓取凡客商品名称和价格demo
- 【Python】抓取京东列表页商品信息(selenium)
- python抓取京东商城的商品名称和价格
- [Python] (多线程版本)抓取聚划算页面商品分析页面获取商品信息并以XML格式保存到本地
- <四>、python爬虫抓取购物网站商品信息--图片价格名称
- python爬虫selenium+firefox抓取京东商品评论
- python抓取京东商品颜色&beautifulsoup的一些常用函数
- python根据京东商品url获取产品价格
- 京东商品的历史价格走势
- [置顶] [爬虫]使用python抓取京东全站数据(商品,店铺,分类,评论)
- Python+Selenium+Chrome抓取京东商品信息
- 【Python】京东商品价格监控
- Python抓取聚划算商品分析页面获取商品信息并以XML格式保存到本地
- 【实例】python 使用beautifulSoup 抓取网页正文 以淘宝商品价格为例
- python爬取京东机票,监控机票,机票价格分析
- Python爬虫学习之抓取商品名称和价格
- python根据京东商品url获取产品价格
- [Python] 抓取聚划算页面商品分析页面获取商品信息并以XML格式保存到本地