本文整理匯總了Python中fetcher.Fetcher.url方法的典型用法代碼示例。如果您正苦於以下問題:Python Fetcher.url方法的具體用法?Python Fetcher.url怎麽用?Python Fetcher.url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fetcher.Fetcher
的用法示例。
在下文中一共展示了Fetcher.url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from fetcher import Fetcher [as 別名]
# 或者: from fetcher.Fetcher import url [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)