def generate_erps_dict(self):
async with clients.aiohttp_session.get("http://www.umop.com/rps101/alloutcomes.htm") as resp:
data = await resp.text()
raw_text = BeautifulSoup(data).text
raw_text = re.sub("\n+", '\n', raw_text).strip()
raw_text = raw_text.lower().replace("video game", "game")
raw_text = raw_text.split('\n')[:-1]
objects = {}
object = raw_text[0].split()[-1]
object_info = {}
for line in raw_text[1:]:
if line[0].isdigit():
objects[object] = object_info
object = line.split()[-1]
object_info = {}
else:
object_info[line.split()[-1]] = ' '.join(line.split()[:-1])
objects[object] = object_info
with open("data/erps_dict.json", 'w') as erps_file:
json.dump(objects, erps_file, indent = 4)
评论列表
文章目录