本文整理汇总了Python中collector.Collector.scrape_sites方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.scrape_sites方法的具体用法?Python Collector.scrape_sites怎么用?Python Collector.scrape_sites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collector.Collector
的用法示例。
在下文中一共展示了Collector.scrape_sites方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import scrape_sites [as 别名]
#!/usr/bin/env python
from collector import Collector
import sys
debug = len(sys.argv) > 1 and sys.argv[1] == '-d'
collector = Collector('config/venues.yml', 'venue_parsers', debug)
shows = collector.scrape_sites()
for venue, venue_shows in shows.items():
print venue
for show in venue_shows:
print '\t', show['headliner']
if 'openers' in show:
print '\t\t', show['openers']
print '\t\t(', show['time'], ') ', show['date']
示例2: Environment
# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import scrape_sites [as 别名]
#!/usr/bin/env python
from collector import Collector
from jinja2 import Environment, FileSystemLoader
import sys
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('rentals.html')
debug = len(sys.argv) > 1 and sys.argv[1] == '-d'
collector = Collector('config/agencies.yml', 'agency_parsers', debug)
collector.load_log('rentals')
agency_listings = collector.scrape_sites()
for agency, listings in agency_listings.items():
print agency.capitalize().replace('_', ' ')
for listing in listings:
print '\t', listing['title']
print '\t\tPrice: ', listing['price']
print '\t\tAddress: ', listing['address']
print '\t\tBed/Bath: ', listing['bed/bath']
print '\t\tSize: ', listing['size'], ' sq ft'
print '\t\tURL: ', listing['url']
collector.write_log(agency_listings, 'rentals')
rendered_page = template.render(agency_listings=agency_listings)
f = open('rentals.html', 'w')