-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
50 lines (44 loc) · 1019 Bytes
/
parse.py
File metadata and controls
50 lines (44 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from bs4 import*
from unidecode import unidecode
import json
def plaintext(url):
soup = BeautifulSoup(url, features="html.parser")
text = soup.get_text()
unicodetext = unidecode(text)
return unicodetext
def get_title(x):
data = json.loads(x)
title = data["title"]
if title == "":
return "Sans titre"
else:
return title
def get_author(y):
data = json.loads(y)
author = data["author"]
if author == "":
return "???"
else:
return author
def get_notes(z):
data = json.loads(z)
return data["notes"]
def get_paste(t):
data = json.loads(t)
return data["paste"]
def get_pokes(p):
sets = p.split("\r\n\r\n")
team = []
for set in sets:
l = set.split("\r\n")[0].replace("(M)","").replace("(F)","").replace(" ","")
if "(" and ")" in l:
#print("y " + l)
l = l[ l.find( '(' )+1 : l.find( ')' ) ]
team.append(l)
elif "@" in l:
#print("n " + l)
l = l.split("@")[0]
team.append(l)
else:
team.append(l)
return team