-2
I made a web scraper using the modules BeautifulSoup
and requests
, that takes the definition and example of concepts in Urban Dictionary. This is code, using the word "reparation" as an example.
word = 'reparation'
r = requests.get("http://www.urbandictionary.com/define.php?term={}".format(word))
soup = BeautifulSoup(r.content, features='html.parser')
definition = soup.find("div", attrs={"class": "meaning"}).text
example = soup.find("div", attrs={"class": "example"}).text
The program returns the site example as:
"Bob: Here is $50 for me Hitting you. Charles: Thanks for the reparation."
However, there are two line breaks on the site, leaving the example as:
"Bob: Here is $50 for me Hitting you.
Charles: Thanks for the reparation."
How do I embed these breaks in the string example
?