【发布时间】:2021-06-21 06:46:58
【问题描述】:
这可能是一个新手问题,但是我已经阅读了整个 bs4 文档并且正在努力寻找解决我的问题的方法。
我基本上有一个 BeautifulSoup 对象,我从中调用 .find() 来定位某个 div,然后我想在这个 div 上调用 .find_all() 。 我尝试过这样的事情:
soup = bs4.BeautifulSoup(browser.page_source, "lxml")
competition = soup.find("div", class_="accordion-competition__content_main").contents
events = competition.find_all("div", class_="sport-event-card")
for event in competition:
print("EVENT: ", event)
无济于事。
如何使用 BS4 过滤已过滤的部分?任何帮助是极大的赞赏。我一直在这个问题上磕磕绊绊,但还没有找到合适的解决方案来过滤一个部分。
【问题讨论】:
标签: python web-scraping beautifulsoup