本文介绍两种抓取价格的方法
1、读取接口获取价格 scrapy等等。。简单
2、基于模拟浏览器读取页面抓取selenium 简单
京东商品价格目前是基于api接口获取然后通过js进行数值初始化
一、基于selenium模拟浏览器进行抓取
In [11]: from selenium import webdriver
In [12]: drive = webdriver.PhantomJS()
In [13]: driver.get("https://item.jd.com/12608054023.html")
In [14]: driver.find_element_by_class_name("price").text
Out[14]: u'119.00'
In [15]: driver.find_element_by_class_name("p-price-plus").text
Out[15]: u'\uffe5109.00'
In [16]: print driver.find_element_by_class_name("p-price-plus").text
¥109.00
In [17]: driver.find_element_by_class_name("p-price").text
Out[17]: u'\uffe5119.00'
In [18]: print driver.find_element_by_class_name("p-price").text
导入到BeautifulSoup处理
from bs4 import BeautifulSoup as bs
pageSo