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


Python BeautifulSoup.BeautifulStoneSoup方法代码示例

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


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

示例1: soup_maker

# 需要导入模块: import BeautifulSoup [as 别名]
# 或者: from BeautifulSoup import BeautifulStoneSoup [as 别名]
def soup_maker(fh):
    """ Takes a file handler returns BeautifulSoup"""
    try:
        from bs4 import BeautifulSoup
        soup = BeautifulSoup(fh, "lxml")
        for tag in soup.find_all():
            tag.name = tag.name.lower()
    except ImportError:
        from BeautifulSoup import BeautifulStoneSoup
        soup = BeautifulStoneSoup(fh)
    return soup 
开发者ID:greedo,项目名称:python-xbrl,代码行数:13,代码来源:xbrl.py

示例2: save_custom_temp_path

# 需要导入模块: import BeautifulSoup [as 别名]
# 或者: from BeautifulSoup import BeautifulStoneSoup [as 别名]
def save_custom_temp_path(self, custom_path):
        with open(CONFIG_FILE, 'r') as conf_file:
            XML_conf_data = conf_file.read().replace('\n', '')
        soup = Soup(XML_conf_data)
        custom_tmp_path_tag = soup.configuration.client.custom_temp_path
        custom_tmp_path_tag['path'] = 'Updated'

        return True 
开发者ID:lakewik,项目名称:EasyStorj,代码行数:10,代码来源:backend_config.py

示例3: get_contest_mark

# 需要导入模块: import BeautifulSoup [as 别名]
# 或者: from BeautifulSoup import BeautifulStoneSoup [as 别名]
def get_contest_mark(contest_id, problem_id, ya_login):
    results_req = FakeResponse()
    contest_mark = None
    user_id = None
    ya_login = convert_to_contest_login(ya_login)
    try:
        results_req = requests.get(
            settings.CONTEST_URL + 'action/api/download-log?contestId=' + str(contest_id) + '&snarkKey=spike')
        try:
            contest_dict = xmltodict.parse(results_req.content)

            users = contest_dict['contestLog']['users']['user']

            for user in users:
                if convert_to_contest_login(user['@loginName']) == ya_login:
                    user_id = user['@id']
                    break

            submits = contest_dict['contestLog']['events']['submit']
            submits.reverse()

            for submit in submits:
                if submit['@userId'] == user_id and submit['@problemTitle'] == problem_id \
                        and submit['@verdict'] == 'OK':
                    contest_mark = submit['@score']
                    break
        except:  # noqa
            soup = BeautifulStoneSoup(results_req.content)
            users = soup.contestlog.users.user

            while users:
                if users != '\n':
                    if convert_to_contest_login(users['loginname']) == ya_login:
                        user_id = users['id']
                        break
                users = users.next

            submits = soup.contestlog.events.submit

            while submits:
                if submits != '\n' and submits.name != 'testinglog' and 'userid' in submits:
                    if submits['userid'] == user_id and submits['problemtitle'] == problem_id \
                            and submits['verdict'] == 'OK':
                        contest_mark = submits['score']
                        break
                submits = submits.next

    except Exception as e:
        logger.exception("Exception while request to Contest: '%s', Exception: '%s'",
                         results_req.url, e)
    return contest_mark 
开发者ID:znick,项目名称:anytask,代码行数:53,代码来源:common.py


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