【问题标题】:Beautifulsoup dont scrape the div style elementBeautifulsoup 不刮掉 div 样式元素
【发布时间】:2022-01-14 08:35:39
【问题描述】:
from requests_html import HTMLSession
from bs4 import BeautifulSoup

url = 'https://kephiso.webuntis.com/WebUntis/monitor?school=Kurt-Schwitters-Schule&monitorType=subst&format=Klassen'


session = HTMLSession()


resp = session.get(url)
resp.html.render()
html = resp.html.html

page_soup = BeautifulSoup(html, 'html.parser')
print(page_soup)

我需要刮掉 div 样式元素的内部,但是控制台只给了我 div 类。

【问题讨论】:

  • 你没有选择任何元素,只是打印纯 HTML。

标签: html beautifulsoup styles children scrape


【解决方案1】:

就像@baduker 在他的评论中所说,你没有用你的代码选择任何东西。您需要找到带有类似style = page_soup.find('style') 的样式标签。

这只适用于这里,因为只有一种风格。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 2019-06-16
    • 1970-01-01
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多