0

I am new to data scraping and I am using BeautifulSoup to grap some data from a webpage. I'm trying to get the r100 in the span tag. I know r100 is the class name, but this data is required. Is it possible?

my code

st2=st1.find("span",attrs={"class":"rating"})
print(st2)

out

<span class="rating r100"></span>
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45

2 Answers2

2

Extract the class then index. It is a multi-valued class with 2 values i.e. 1 at index 0 and the other at index 1.

st2['class'][1]
QHarr
  • 83,427
  • 12
  • 54
  • 101
0

One you have <span class="rating r100"></span> in st2. You can use text

Code st2.text

Also, you can use get_text() which will allow you to pass more arguments such as

(separator, strip, types)

Buddy Bob
  • 5,829
  • 1
  • 13
  • 44