当前位置: 首页>>代码示例>>Python>>正文


Python PyQuery.startswith方法代码示例

本文整理汇总了Python中pyquery.PyQuery.startswith方法的典型用法代码示例。如果您正苦于以下问题:Python PyQuery.startswith方法的具体用法?Python PyQuery.startswith怎么用?Python PyQuery.startswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyquery.PyQuery的用法示例。


在下文中一共展示了PyQuery.startswith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseProductDetails

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import startswith [as 别名]
 def parseProductDetails(self, product_page_content, product_info):
     doc = PyQuery(product_page_content)
     product_info['name'] = doc('h1#div_product_name').text()
     product_info['sku_id'] = doc('span#div_product_itemno').text()
     product_info['price'] = doc('span#div_product_price').text()
     product_info['label_price'] = doc('span#div_retail_price').text()
     product_info['img_url'] = self.merchant.filteruri(doc('img#target_img').attr('src'))
     #获取reviews数目
     product_info['reviews'] = '0'
     bNodeList = doc('b')
     for item in bNodeList:
         text = PyQuery(item).text()
         if text.startswith("Customer Reviews"):
             product_info['reviews'] = extractNum(text)
             break
     #获取品类路径
     nodeList = doc('a.nav-location')
     if PyQuery(nodeList[0]).text().strip() == 'Home':
         nodeList = nodeList[1:]
     for i, node in enumerate(nodeList):
         product_info['level' + str(i+1) + '_category'] = PyQuery(node).text().strip()
开发者ID:chenweiqiang2016,项目名称:cwq-crawler,代码行数:23,代码来源:bestwigoutlet.py

示例2: PyQuery

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import startswith [as 别名]
# Download Pixelmator tutorial videos from vimeo.
# by twinsant
import requests
from pyquery import PyQuery

from savevideo import get_download_links
from savevideo import download_video

if __name__ == '__main__':
    # Get all vimeo urls in tutorial page
    session = requests.Session()
    r = session.get('http://www.pixelmator.com/tutorials/')
    d = PyQuery(r.text.encode('utf8'))
    hrefs = d('a')
    urls = set()
    for href in hrefs:
        a = PyQuery(href).attr.href
        if a.startswith('https://vimeo.com'):
            urls.add(a)
    for url in sorted(list(urls)):
        print 'Get video links for %s' % url
        # With help of savevideo.me
        links = get_download_links(url)
        for link in links:
            video_url, profile = link
            # Exclude HD and Mobile versions
            if profile.find('(MP4 format)')!=-1:
                download_video(video_url)
开发者ID:twinsant,项目名称:savevideo,代码行数:30,代码来源:pixelmator_tut.py


注:本文中的pyquery.PyQuery.startswith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。