0
votes

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>
2
What output are you looking for exactly? - Mad Physicist
I only want 100 - Aygün Çalışkan

2 Answers

2
votes

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]
0
votes

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)