本文整理汇总了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()
示例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)