mysmartprice的一个简单的基于抓取的python库

python-smartprice的Python项目详细描述


BuildCodeRatepypi

python智能价格

一个简单的基于抓取的python库,用于mysmartprice-price比较站点。

简介

MySmartPrice是一个平台,它提供了各种类别的畅销书价格,包括手机、电子产品、计算机、时尚和生活方式、相机、书籍、电器和个人护理。

安装

pip install python-smartprice

先决条件

  • 请求
  • 美化组4
  • Python2.7+

快速启动

获取价目表

检查下面所有的Supported attributes

>>>frompysmartprice.baseimportSmartPrice>>>smartprice=SmartPrice()>>>len(smartprice.samsung_mobiles)Out[5]:142>>>smartprice.samsung_mobilesOut[6]:[<pysmartprice.results.SmartPriceResultat0x10df46f90>,<pysmartprice.results.SmartPriceResultat0x10df46fd0>,<pysmartprice.results.SmartPriceResultat0x10df50050>,<pysmartprice.results.SmartPriceResultat0x10df50090>,<pysmartprice.results.SmartPriceResultat0x10df500d0>,<pysmartprice.results.SmartPriceResultat0x10df50110>,<pysmartprice.results.SmartPriceResultat0x10df50150>,<pysmartprice.results.SmartPriceResultat0x10df50190>]>>>samsung_mobile=smartprice.samsung_mobiles[0]>>>samsung_mobile.titleOut[7]:u'Samsung Galaxy J7'>>>samsung_mobile.best_priceOut[8]:'14,299'>>>samsung_mobile.dumptojsonOut[9]:{u'best_price':u'14,664',u'img':u'http://c0028545.cdn1.cloudfiles.rackspacecloud.com/7178-7-thumb.jpg',u'product_id':u'7178',u'title':u'\nSamsung Galaxy J7\n',u'url':u'http://www.mysmartprice.com/mobile/samsung-galaxy-j7-msp7178'}

搜索价目表

>>>frompysmartprice.baseimportSmartPrice>>>smartprice=SmartPrice()>>>smartprice.search('SAMSUNG')Out[4]:[<pysmartprice.results.SmartPriceResultat0x102b05990>,<pysmartprice.results.SmartPriceResultat0x100d36850>,<pysmartprice.results.SmartPriceResultat0x1024129d0>,<pysmartprice.results.SmartPriceResultat0x102412b10>,<pysmartprice.results.SmartPriceResultat0x102412f90>,<pysmartprice.results.SmartPriceResultat0x102412fd0>,<pysmartprice.results.SmartPriceResultat0x102412e10>,<pysmartprice.results.SmartPriceResultat0x102412d50>,<pysmartprice.results.SmartPriceResultat0x102412c50>,...]In[3]:len(s.search('SAMSUNG'))Out[3]:1012In[3]:results=s.search('SAMSUNG')In[4]:results[0].dumptojsonOut[4]:{u'best_price':u'14,664',u'img':u'http://c0028545.cdn1.cloudfiles.rackspacecloud.com/7178-7-thumb.jpg',u'product_id':u'7178',u'title':u'\nSamsung Galaxy J7\n',u'url':u'http://www.mysmartprice.com/mobile/samsung-galaxy-j7-msp7178'}

获取卖家详细信息

>>frompysmartprice.baseimportSmartPrice>>smartprice=SmartPrice()>>results=smartprice.sellers('Samsung Galaxy J2')>>resultsOut[4]:[<pysmartprice.results.SmartPriceResultat0x109eca590>]In[5]:results[0].dumptojsonOut[5]:{'best_price':'8,199','img':'http://c0028545.cdn1.cloudfiles.rackspacecloud.com/7448-6-thumb.jpg','product_id':'7448','title':'Samsung Galaxy J2','sellers':[{'logo':u'http://c223968.r68.cf1.rackcdn.com/syberplace_store.png','name':u'Seller:\nSyberplace','price':u'8,199','rating':u'5/5'},{'logo':u'http://c223968.r68.cf1.rackcdn.com/amazon_store.png','name':u'Seller:Amazon Seller','price':u'8,330','rating':u'4.5/5'},{'logo':u'http://c223968.r68.cf1.rackcdn.com/ebay_store.png','name':u'Seller:Bberry.stores','price':u'8,215','rating':u'5/5'},{'logo':u'http://c223968.r68.cf1.rackcdn.com/paytm_store.png','name':u'Seller:RYAISHA RETAILS PVT LTD','price':u'8,496','rating':u'3.2/5'},{'logo':u'http://c223968.r68.cf1.rackcdn.com/indiatimes_store.png','name':u'Seller:Indiatimes','price':u'8,314','rating':u'2.5/5'},{'logo':u'http://c223968.r68.cf1.rackcdn.com/flipkart_store.png','name':u'Seller:WS Retail','price':u'8,499','rating':u'4.2/5'}],'url':'http://www.mysmartprice.com/mobile/samsung-galaxy-j2-msp7448'}

支持的属性

获得以下属性的最佳价格

  • 手机
  • 三星手机
  • 诺基亚手机
  • Micromax_手机
  • iPhone
  • 宏达电手机
  • 药片
  • 三星电子平板电脑
  • 联想平板电脑
  • Micromax_平板电脑
  • 苹果iPad
  • 笔记本电脑
  • 惠普笔记本电脑
  • 戴尔笔记本电脑
  • 联想笔记本电脑
  • 索尼笔记本电脑
  • 东芝笔记本电脑
  • MacBooks
  • 三星电脑
  • 电视
  • 三星电视
  • 索尼电视
  • LG电视
  • 松下电视
  • 夏普电视

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法启动应用程序:JNLP错误   java根据用户输入在PreparedStatement中使用setTime()或setNull()   java EJB与同步   java以object为键通过hashmap进行搜索   java中的模10^9+7   针对包含其他对象的对象的java OOP最佳实践   如何将字符串作为HTML代码从Java文件读取到JSP页面?   java我的POM怎么了?“解析表达式..检测到递归表达式循环”   用于Hbase的Mapreduce的java NoSuchMethodError   JAVAlang.SecurityException:权限拒绝:启动意图{act=安卓.Intent.action.MAIN cat=[安卓.Intent.category.LAUNCHER]   数组初始化谜语Java   通过arraylist搜索时的java句柄关联