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抓取京东价格分析京东商品价格走势请关注haodaima.com其它相关文章!