当前位置: 首页>>代码示例>>Python>>正文


Python Scraper.registered_manga方法代码示例

本文整理汇总了Python中scraper.Scraper.registered_manga方法的典型用法代码示例。如果您正苦于以下问题:Python Scraper.registered_manga方法的具体用法?Python Scraper.registered_manga怎么用?Python Scraper.registered_manga使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scraper.Scraper的用法示例。


在下文中一共展示了Scraper.registered_manga方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DentonBot

# 需要导入模块: from scraper import Scraper [as 别名]
# 或者: from scraper.Scraper import registered_manga [as 别名]
class DentonBot(pyrc.Bot):
    def __init__(self, *args, **kwargs):
        super(DentonBot, self).__init__(*args, **kwargs)
        self.scraper = Scraper()

        # todo: add mangastream to these as well
        self.scraper.add_manga("One Piece", ["mangahere"])
        self.scraper.add_manga("Bleach", ["mangahere"])
        self.scraper.add_manga("Naruto", ["mangahere"])
        self.scraper.add_manga("Fairy Tail", ["mangahere"])

        self.scraper.add_manga("Toriko", ["mangahere"])
        self.scraper.add_manga("Cage of Eden", ["mangahere"])
        self.scraper.add_manga("Gamaran", ["mangahere"])
        self.scraper.add_manga("Magi", ["mangahere"])
        self.scraper.add_manga("Shaman King Flowers", ["mangahere"])
        self.scraper.add_manga("Soul Eater", ["mangahere"])
        self.scraper.add_manga("The Breaker: New Waves", ["mangahere"])
        self.scraper.add_manga("The World God Only Knows", ["mangahere"])
        self.scraper.add_manga("Until Death Do Us Part", ["mangahere"])
        self.scraper.add_manga("Witch Hunter", ["mangahere"])
        self.scraper.add_manga("Yotsubato!", ["mangahere"])

    @hooks.command(r"help|advice")
    def help(self, channel):
        self.message(channel, random.choice(advice))

    @hooks.command(r"list|registered")
    def registered(self, channel):
        manga = self.scraper.registered_manga()
        manga_str = ", ".join(manga)
        self.message(channel, "Registered manga include %s" % manga_str)

    @hooks.command("fetch manga")
    def fetch_manga(self, channel):
        results = self.scraper.get_all_manga()
        for (name, chapter, link) in results:
            self.message(channel, "%s %i: %s" % (name, chapter, link))

    @hooks.command(r"last (?P<manga_name>.*)")
    def last(self, channel, manga_name):
        manga_name = manga_name.strip()
        manga_name = aliases.get(manga_name, manga_name)
        manga_tuple = self.scraper.get_manga(manga_name)
        if manga_tuple and not manga_tuple[2]:
            self.message(channel, "Sorry, don't have the latest %s" % manga_tuple[0])
        elif manga_tuple:
            self.message(channel, "%s %i: %s" % manga_tuple)
        else:
            self.message(channel, "I'm not big into books")

    @hooks.interval(2 * 60 * 1000)
    def scrape(self):
        results = self.scraper.scrape()
        for (name, chapter, link) in results:
            msg = "New %s (%i): %s" % (name, chapter, link)
            for channel in CHANNELS:
                self.message(channel, msg)

    def close(self):
        super(DentonBot, self).close()
开发者ID:CarlosFdez,项目名称:denton_manga_scraper,代码行数:63,代码来源:main.py


注:本文中的scraper.Scraper.registered_manga方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。