Web Scraping Beautiful Soup

Why int and then float i wrote it cuz i saw it in a solution code but i don’t understand. I also don’t understand why sometimes we use
cocoa_data= soup.select(".CocoaPercent")
but other times
ratings_all = soup.find_all(attrs={‘class’:‘Rating’})
Are they used the same way or does it depend on the situation?

for td in cocoa_data[1:]:

percent= int(float(td.get_text().strip("%")))

cocoa_perc.append(percent)

df[“CocoaPercentage”] = cocoa_perc

df.head()

b/c you want to convert a floating point number to an integer (and you’re stripping away the % as well).
https://docs.python.org/3/library/functions.html#int

as for soup.select() and soup.find_all():

.select() will accept CSS selectors and locate them and will return a list
.find_all() does not. It will return whatever you specify it to.

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find

beautiful soup docs here:
https://beautiful-soup-4.readthedocs.io/en/latest/#kinds-of-objects