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


Python Utils.decode_dict方法代码示例

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


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

示例1: _download_openphish

# 需要导入模块: from utils.utils import Utils [as 别名]
# 或者: from utils.utils.Utils import decode_dict [as 别名]
    def _download_openphish(self, path_in, user_agent, url_feed, username, password):
        logging.debug("Downloading OpenPhish feeds...")
        try:
            password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
            password_manager.add_password(None, url_feed, username, password)

            auth = urllib2.HTTPBasicAuthHandler(password_manager)
            opener = urllib2.build_opener(auth)
            opener.addheaders = [('User-agent', user_agent)]
            urllib2.install_opener(opener)

            request = urllib2.Request(url_feed)
            handler = urllib2.urlopen(request)

            count = 0
            json_str = ''
            for d in handler.readlines():
                if count == 0:
                    json_str = '{'
                json_str += '\"phish_' + str(count) + "\" : " + d.strip() + ', \n'
                count = count + 1
            json_str = json_str[:-3] + '}'
            json_obj = json.loads(json_str)
            json_obj = Utils.decode_dict(json_obj)

            with open(os.path.join(path_in, 'openphish.txt'), 'w') as f:
                json.dump(json_obj, f, ensure_ascii=False)
        except Exception, e:
            logging.error("Error downloading OpenPhish feed '%s': %s" % (url_feed, e))
            raise Exception
开发者ID:boh717,项目名称:phishunter,代码行数:32,代码来源:downloader.py


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