本文整理匯總了Python中spider.Spider.htmlCallback方法的典型用法代碼示例。如果您正苦於以下問題:Python Spider.htmlCallback方法的具體用法?Python Spider.htmlCallback怎麽用?Python Spider.htmlCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spider.Spider
的用法示例。
在下文中一共展示了Spider.htmlCallback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: response
# 需要導入模塊: from spider import Spider [as 別名]
# 或者: from spider.Spider import htmlCallback [as 別名]
def response (url, response):
"""A response has been recieved from the spider when contacting a url"""
log.info("Processing %s" % url)
def htmlCallback(url, html):
"""Html has been found in the response"""
log.info(html)
def linkCallback(parentUrl, linkUrl, element):
"""A link has been found in the page being spidered"""
log.info("Link Found: %s %s %s" % (parentUrl, linkUrl, str(element)))
def levelCallback(levelNumber):
"""A new level of the page is being started"""
log.info("Spidering level %d" % levelNumber)
if __name__ == '__main__':
logging.basicConfig(level = logging.INFO,
format = "%(asctime)s %(levelname)s %(threadName)s: %(message)s")
spider = Spider(args.url, threads=args.threads, maxDepth=args.depth)
spider.responseCallback = response
spider.htmlCallback = htmlCallback
spider.linkCallback = linkCallback
spider.levelCallback = levelCallback
spider.spider()