本文整理汇总了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
示例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
示例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