【问题标题】:How can I get all child classes in BeautifulSoup4?如何在 BeautifulSoup4 中获取所有子类?
【发布时间】:2020-11-04 19:48:46
【问题描述】:
from bs4 import BeautifulSoup
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
tables = soup.select('div.GMBodyMid')
table = tables[0]
table_html = str(table)
table_df_list = pd.read_html(table_html)
table_df = table_df_list[0]
data = pd.DataFrame(table_df)

我试图获得所有课程,但只有 'GMPageFirst' 课程获得了 3 次。 我怎样才能获得“GMBodyMid”课程中的所有课程?

【问题讨论】:

  • 你可以试试:tables = soup.find_all("div", class_="GMBodyMid ")
  • 我认为你想做什么非常不清楚。
  • 可以分享网址吗?
  • @CarlosBazilio 我试过了,但我只能提取 'GMPageFirst' 类
  • @AndrejKesely 该网站需要登录..

标签: python html python-3.x beautifulsoup web-crawler


【解决方案1】:

使用这个:

tables = soup.select('div' ,attrs={"class":"GMBodyMid"})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-08
    • 2011-03-29
    • 2019-07-19
    • 1970-01-01
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多