Python: How to scrape the string 7.7872 in <span class=’pos’><span class=’arr_ud arrow_u5′> </span>&nbsp;7.7872</span>

  beautifulsoup, python, python-3.x, web-scraping

I am trying to scrape the following line and extract the value of 7.7872, how to I make it work?

<span class='pos'><span class='arr_ud arrow_u5'> </span>&nbsp;7.7872</span>

I tried the following code but there is some blank string which I cannot get ride off:

for a in soupUSD.find_all("span", attrs={"class":"pos"})[0]:
    print(a)

I have the following result:

<span class='arr_ud arrow_u5'> </span>&nbsp;7.7872

Any way I can just find the text of 7.7872 only?

Source: Python Questions

LEAVE A COMMENT