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


Python Match.get_url_kind方法代码示例

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


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

示例1: main

# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import get_url_kind [as 别名]
def main():
    debug = False

    def version():
        log.info_log('version %s' % __version__)
    try:
        opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
    except getopt.GetoptError as err:
        log.error_log(u"Try ee-book --help for more options")
        sys.exit(2)
    for option, args in opts:
        if option in ('-V', '--version'):
            version()
            sys.exit()
        elif option in ('-d', '--debug'):
            print u"Debug mode..."
            debug = True
        elif option in ('-h', '--help'):
            version()
            print(help_info)
            sys.exit()
        elif option in ('-g', '--gui'):
            print(u"Under developing...")
            sys.exit()
            # graphviz = GraphvizOutput(output_file='filter_gui.png')
            # with PyCallGraph(output=graphviz, config=config):
            # from PyQt4.QtGui import QApplication
            # from PyQt4.QtGui import QIcon
            # from src.gui.ui import MainWindow
            # from src.resources import qrc_resources
            # app = QApplication(sys.argv)
            # app.setWindowIcon(QIcon(":/icon.png"))
            # app.setApplicationName('EE-Book')
            # window = MainWindow()
            # window.show()
            # sys.exit(app.exec_())
        elif option in ('-l', '--login'):
            url = args
            try:
                recipe_kind = Match.get_url_kind(url)
            except UnsupportTypeException, e:
                print e
                print u"Please try again."
                sys.exit()
            zhihu = EEBook(recipe_kind=recipe_kind)    # Init path, e.g. config, only zhihu are supported now
            login = Login(recipe_kind=recipe_kind)
            login.start()
            sys.exit()
        elif option in ('-u', '--url'):
            url = args
            try:
                recipe_kind = Match.get_website_kind(url)
            except UnsupportTypeException, e:
                print e
                print u"Please check url."
                sys.exit()
开发者ID:bindx,项目名称:EE-Book,代码行数:58,代码来源:ee-book.py

示例2: main

# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import get_url_kind [as 别名]
def main():
    debug = False

    def version():
        log.info_log('version %s' % __version__)
    try:
        opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
    except getopt.GetoptError as err:
        log.error_log(u"Try ee-book --help for more options")
        sys.exit(2)
    for option, args in opts:
        if option in ('-V', '--version'):
            version()
            sys.exit()
        elif option in ('-d', '--debug'):
            print u"Debug mode..."
            debug = True
        elif option in ('-h', '--help'):
            version()
            print(help_info)
            sys.exit()
        elif option in ('-g', '--gui'):
            print(u"Under developing...")
            sys.exit()
            # graphviz = GraphvizOutput(output_file='filter_gui.png')
            # with PyCallGraph(output=graphviz, config=config):
            # from PyQt4.QtGui import QApplication
            # from PyQt4.QtGui import QIcon
            # from src.gui.ui import MainWindow
            # from src.resources import qrc_resources
            # app = QApplication(sys.argv)
            # app.setWindowIcon(QIcon(":/icon.png"))
            # app.setApplicationName('EE-Book')
            # window = MainWindow()
            # window.show()
            # sys.exit(app.exec_())
        elif option in ('-l', '--login'):
            url = args
            recipe_kind = Match.get_url_kind(url)
            if recipe_kind != 'zhihu':
                print("Unsupport type! Only zhihu are supported now.\n Please try again.")
                sys.exit()
            zhihu = EEBook(recipe_kind=recipe_kind)    # Init path, e.g. config, only zhihu are supported now
            login = Login(recipe_kind=recipe_kind)
            login.start()
            sys.exit()
        elif option in ('-u', '--url'):
            url = args
            recipe_kind = Match.get_website_kind(url)
            if recipe_kind == 'Unsupport type':
                print("Unsupported type!\n Please try again.")
                sys.exit()
            game = EEBook(recipe_kind=recipe_kind, url=url, debug=debug)
            game.begin()
            sys.exit()
        elif option in ('-i', '--info'):
            url = args
            url_kind = Match.get_url_kind(url)
            if url_kind == 'Unknown type':
                print('Unsupported website or url type. \nPlease check url.')
            else:
                info = url_info[url_kind]
                print(info)
            sys.exit()
        elif option in('-r', '--file'):
            file_name = args
            log.print_log(u'read from %s' % file_name)

            counter = 1
            try:
                with open(file_name, 'r') as read_list:
                    read_list = read_list.readlines()
                    line = read_list[0]
                    recipe_kind = Match.get_website_kind(line)
                    counter += 1
                    if recipe_kind == 'Unsupport type':
                        print('Unsupported website or url type. \nPlease check url.')
                        sys.exit()
            except IOError as e:
                Debug.logger.debug(u"\nCreating " + file_name + "...")
                with open(file_name, 'w') as read_list:
                    read_list.close()
            if 1 == counter:
                print(u"\nOops! No content in " + file_name + u". Please check it out.")
                sys.exit()

            print(u"website type:" + str(recipe_kind))
            game = EEBook(recipe_kind=recipe_kind, url=None, read_list=file_name)
            game.begin()
            sys.exit()
        elif option in('-c', '--cookies'):
            cookie_file = args
            print("Cookie_file:" + cookie_file)
            print("TODO: read from cookie to login")
            # with open(cookie_file) as f:
            #     content = f.read()
            # game = EEBook(recipe_kind='zhihu')
            # from src.tools.db import DB
            # from src.tools.extra_tools import ExtraTools
            # DB.execute('delete from LoginRecord')  # 登陆成功后清除数据库中原有的登录记录,避免下次登陆时取到旧记录
#.........这里部分代码省略.........
开发者ID:mozii,项目名称:EE-Book,代码行数:103,代码来源:ee-book.py

示例3: in

# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import get_url_kind [as 别名]
            login.start()
            sys.exit()
        elif option in ('-u', '--url'):
            url = args
            try:
                recipe_kind = Match.get_website_kind(url)
            except UnsupportTypeException, e:
                print e
                print u"Please check url."
                sys.exit()
            game = EEBook(recipe_kind=recipe_kind, url=url, debug=debug)
            game.begin()
            sys.exit()
        elif option in ('-i', '--info'):
            url = args
            url_kind = Match.get_url_kind(url)
            if url_kind == 'Unknown type':
                print('Unsupported website or url type. \nPlease check url.')
            else:
                info = url_info[url_kind]
                print(info)
            sys.exit()
        elif option in('-r', '--file'):
            file_name = args
            log.print_log(u'read from %s' % file_name)

            counter = 1
            try:
                with open(file_name, 'r') as read_list:
                    read_list = read_list.readlines()
                    line = read_list[0]
开发者ID:bindx,项目名称:EE-Book,代码行数:33,代码来源:ee-book.py


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