如果要等待页面完全加载其数据,则应考虑使用硒,在您的情况下,它可能看起来像这样:
from bs4 import BeautifulSoupfrom selenium.webdriver import Chromefrom selenium.webdriver.chrome.options import Optionsurl = "<URL>"chrome_options = Options() chrome_options.add_argument("--headless") # Opens the browser up in backgroundwith Chrome(options=chrome_options) as browser: browser.get(url) html = browser.page_sourcepage_soup = BeautifulSoup(html, 'html.parser')containers = page_soup.findAll("div",{"class":"grid-item"})


