本文整理汇总了Python中src.tools.match.Match.detect_recipe_kind方法的典型用法代码示例。如果您正苦于以下问题:Python Match.detect_recipe_kind方法的具体用法?Python Match.detect_recipe_kind怎么用?Python Match.detect_recipe_kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.tools.match.Match
的用法示例。
在下文中一共展示了Match.detect_recipe_kind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_command
# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import detect_recipe_kind [as 别名]
#.........这里部分代码省略.........
task.spider.href_article_list = 'http://blog.sina.com.cn/s/articlelist_{}_0_1.html'.\
format(sinablog_author_id)
task.spider.href = 'http://blog.sina.com.cn/u/{}'.format(sinablog_author_id)
task.spider.href_profile = 'http://blog.sina.com.cn/s/profile_{}.html'.format(sinablog_author_id)
task.book.kind = 'sinablog_author'
task.book.sql.info_extra = 'creator_id = "{}"'.format(sinablog_author_id)
task.book.sql.article_extra = 'author_id = "{}"'.format(sinablog_author_id)
task.book.author_id = sinablog_author_id
return task
def parse_jianshu_author(command):
u"""
:param command: homepage of someone, e.g. http://www.jianshu.com/users/b1dd2b2c87a8/latest_articles
:return: task:
"""
result = Match.jianshu_author(command)
jianshu_id = result.group('jianshu_id')
task = SingleTask()
task.author_id = jianshu_id
task.kind = 'jianshu_author'
task.spider.href = 'http://www.jianshu.com/users/{}/latest_articles'.format(jianshu_id)
task.book.kind = 'jianshu_author'
task.book.sql.info_extra = 'creator_id = "{}"'.format(jianshu_id)
task.book.sql.article_extra = 'author_id = "{}"'.format(jianshu_id)
task.book.author_id = jianshu_id
return task
def parse_jianshu_collection(command):
result = Match.jianshu_collection(command)
collection_id = result.group('collection_id')
task = SingleTask()
task.kind = 'jianshu_collection'
task.spider.href = 'http://www.jianshu.com/collection/{}'.format(collection_id)
task.book.kind = 'jianshu_collection'
task.book.sql.info = 'select * from jianshu_collection_info where collection_fake_id = "{}"'.format(
collection_id
)
task.book.sql.answer = 'select * from jianshu_article where href in (select href from ' + \
'jianshu_collection_index where collection_fake_id = "{}")'.format(collection_id)
return task
def parse_jianshu_notebooks(command):
result = Match.jianshu_notebooks(command)
notebooks_id = result.group('notebooks_id')
task = SingleTask()
task.kind = 'jianshu_notebooks'
task.spider.href = 'http://www.jianshu.com/notebooks/{}/latest'.format(notebooks_id) # config file???
task.book.kind = 'jianshu_notebooks'
task.book.sql.info = 'select * from jianshu_notebooks_info where notebooks_id = "{}"'.format(
notebooks_id
)
task.book.sql.answer = 'select * from jianshu_article where href in (select href from ' + \
'jianshu_notebooks_index where notebooks_id = "{}")'.format(notebooks_id)
return task
def parse_csdnblog_author(command):
u"""
:param command: homepage of someone, e.g. http://blog.csdn.net/elton_xiao
:return: task
"""
result = Match.csdnblog_author(command)
csdnblog_author_id = result.group('csdnblog_author_id')
Debug.logger.debug(u"csdnblog_id:" + str(csdnblog_author_id))
task = SingleTask()
task.author_id = csdnblog_author_id
task.kind = 'csdnblog_author'
task.spider.href = 'http://blog.csdn.net/{}'.format(csdnblog_author_id)
task.book.kind = 'csdnblog_author'
task.book.sql.info_extra = 'creator_id = "{}"'.format(csdnblog_author_id)
task.book.sql.article_extra = 'author_id = "{}"'.format(csdnblog_author_id)
task.book.author_id = csdnblog_author_id
return task
def parse_error(command):
if command:
Debug.logger.info(u"""Could not analysis:{}, please check it out and try again。""".format(command))
return
parser = {
'answer': parse_answer,
'question': parse_question,
'author': parse_author,
'collection': parse_collection,
'topic': parse_topic,
'article': parse_article,
'column': parse_column,
'sinablog_author': parse_sinablog_author,
'jianshu_author': parse_jianshu_author,
'jianshu_collection': parse_jianshu_collection,
'jianshu_notebooks': parse_jianshu_notebooks,
'csdnblog_author': parse_csdnblog_author,
'unknown': parse_error,
}
kind = Match.detect_recipe_kind(raw_command)
return parser[kind](raw_command)