本文整理汇总了Python中fetcher.Fetcher.child_urls方法的典型用法代码示例。如果您正苦于以下问题:Python Fetcher.child_urls方法的具体用法?Python Fetcher.child_urls怎么用?Python Fetcher.child_urls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fetcher.Fetcher
的用法示例。
在下文中一共展示了Fetcher.child_urls方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from fetcher import Fetcher [as 别名]
# 或者: from fetcher.Fetcher import child_urls [as 别名]
def run(limit = -1):
if limit != -1 and store.count() > limit:
print 'Limit: ' + str(limit) + ' Count: ' + str(store.count())
print 'Voila, We are done !!'
import sys
sys.exit()
return
if swap.current.is_empty():
if swap.next.is_empty() :
print 'Somehow, We are done'
else:
# we exchange current and new, run again
swap.exchange()
return run(limit)
#get the url from current-to be crawled list of urls
url = swap.current.pop()
if not url or not valid_url(url):
print '"'+url+'" is not a valid url, giving up on it'
return run(limit)
f = Fetcher(url)
next_urls = store.process(f.url(), f.child_urls())
for url in next_urls:
swap.next.push(url)
return run(limit)