python - 网页抓取 : how to extract this kind of div tag?

标签 python selenium selenium-webdriver beautifulsoup

我在看一个标签:
enter image description here .
当我写代码时,

message = soup.find("div", {"class": "text-msg-container"})
它没有给我。什么是_ngcontent-vex-c62data-e2e-text-message-content标签?我也需要包括它们吗?我应该如何编写它们以获取 div 标签?

最佳答案

你不能因为当您发送 GET 时 div 不存在请求获取页面代码。
该页面是使用生成 SPA(单页应用程序)的 Angular 框架构建的,这意味着您不能 当您发送 GET 时从中获取数据请求,因为数据不在那里。
数据是由 Javascript 代码生成的,需要先运行才能将所需的数据添加到网页中。
您需要使用另一种允许 Javascript 代码先运行的方式,然后尝试获取所需的数据。

关于python - 网页抓取 : how to extract this kind of div tag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66626377/

相关文章:

python - 如何为Python安装Flask-mysqldb?

python - 使用 selenium python 复制文本区域

python - 如何在 Chrome 浏览器通过 Python selenium 自动更新时使用特定版本的 ChromeDriver

angularjs - 在没有专用 WebDriver 实现的浏览器上运行 Protractor?

python - python Selenium 包中的格式错误

java - Selenium 说 xpath 定位器无效

python - 尽管索引匹配,但 pd.IndexSlice 的 pd.Series 赋值会导致 NaN 值

python - 并行处理图像像素

python - 将 2d 数组与 3d 数组的每个切片相乘 - Numpy

c# - 如何使用 Selenium Webdriver 和 Internet Explorer 10 处理 Windows 身份验证?