python - Beautiful Soup Returning Unwanted Characters -
i'm using beautiful soup scrape pages trying height of athletes:
req = requests.get(url) soup = beautifulsoup(req.text, "html.parser") height = soup.find_all("strong") height = height[2].contents print height
unfortunately, gets returned:
[u'6\'0"']
i've tried:
height = str(height[2].contents)
and
height = unicode(height[2].contents)
but still [u'6\'0"'] result.
how can have 6'0" returned without characters? help!
those aren't "extra characters". .contents
returns list, element chose has 1 child, , you're getting list containing 1 element. python prints list pseudo python code, can see , what's in it.
perhaps want .string
?
Comments
Post a Comment