mercredi 15 juin 2016

Beautiful Soup Returning Unwanted Characters


I'm using Beautiful Soup to scrape pages trying to get the height of certain athletes:

req = requests.get(url)
soup = BeautifulSoup(req.text, "html.parser")
height = soup.find_all("strong")
height = height[2].contents
print height

Unfortunately, this is what gets returned:

[u'6'0"']

I've also tried:

height = str(height[2].contents)

and

height = unicode(height[2].contents)

but I still get [u'6'0"'] as a result.

How can I just have 6'0" returned without the extra characters? Thanks for your help!


Aucun commentaire:

Enregistrer un commentaire