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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -