我很难理解为什么这个类对象
初始
参数。这是Python3.6。
在一个文件中,我导入一个WebCrawler并将Kwargs传递到其中:
import metacrawler as mc
mc.crawlwrapper(url=archive_url, archive_org=True, index_pages=True, depth_limit=2, fileroot='content/')
调试
:yes,true参数定义为
True
在这一点上。
{'archive_org': True}
进入创建类实例的中间函数。下面是中间函数,它将从第一个函数到爬虫程序的所有内容进行解析:
def crawlwrapper(**kw):
fileroot = kw.get('fileroot','')
url = kw['url']
print('DEBUG(pre):{0}'.format(kw))
depth_limit = kw.get('depth_limit',3)
confine_prefix= kw.get('confine_prefix')
archive_org = kw.get('archive_org',False)
exclude=kw.get('exclude',[])
print_pov=kw.get('print_pov',False)
index_pages = kw.get('index_pages')
print('DEBUG(post): depth_limit, confine_prefix, index_pages, archive_org {0}'.format([depth_limit, confine_prefix, index_pages, archive_org]))
crawler = Crawler(url, depth_limit, confine_prefix, exclude, index_pages, print_pov, archive_org)
crawler.crawl()
这是
Crawler
从crawwrapper(**kw)函数接收kwargs的:
class Crawler(object):
def __init__(self, url, depth_limit, confine=None, exclude=[], locked=True, filter_seen=True, index_pages=True, print_pov=False, archive_org=None):
print('depth_limit {0}, confine {1}, index_pages {2}, archive_org {3}'.format(depth_limit, confine, index_pages, archive_org))
调试
:以下是crawler.crawler()类方法中接收到的内容:
depth_limit 2, confine http://www.cfu.or.ug, index_pages True, archive_org None
注意,Achive_Org从
真的
到
None
是吗?
为什么crawler没有收到我的archive_org=true参数?