diff --git a/functions.py b/functions.py index 80ec6fe..31caf36 100755 --- a/functions.py +++ b/functions.py @@ -60,3 +60,26 @@ def make_toot_markov(query = None): "toot": toot, "media": None } + +def extract_toot(toot): + soup = BeautifulSoup(toot, "html.parser") + for lb in soup.select("br"): #replace
with linebreak + lb.insert_after("\n") + lb.decompose() + + for p in soup.select("p"): #ditto for

+ p.insert_after("\n") + p.unwrap() + + for ht in soup.select("a.hashtag"): #make hashtags no longer links, just text + ht.unwrap() + + for link in soup.select("a"): #ocnvert