2021年1月2日星期六

Why beautiful soup select by class return empty list by find_all works?

I am trying to parse out the top 100 hot hit for a certain day from billboards with beautiful soup. I tried to select the section by class name, but it does not work. I tried to use find_all by class, and it works. Why only find_all works in this case?

from bs4 import BeautifulSoup  import requests    billboard_website = "https://www.billboard.com/charts/hot-100/2019-05-09"  response = requests.get(f"{billboard_website}")  soup = BeautifulSoup(response.text, "html.parser")      print(soup.select(".chart-element__information__song text--truncate color--primary")) # returns an empty list    print(soup.find_all(class_="chart-element__information__song text--truncate color--primary")) # returns the full list  
https://stackoverflow.com/questions/65545425/why-beautiful-soup-select-by-class-return-empty-list-by-find-all-works January 03, 2021 at 08:06AM

没有评论:

发表评论