在python中requestshtml不起作用的情况下取消之前呈现元素

2024-06-02 05:29:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试删除此页(例如): https://super.walmart.com.mx/papel-higienico/papel-higienico-petalo-rendimax-12-rollos-con-320-hojas-dobles/00750194345845

。。。以获得产品价格。通过html请求,我可以在其他页面中获得动态内容,但在沃尔玛上不起作用。我知道我可以用selenium做到这一点,但我正在试图理解为什么它不能处理html请求,以及(如果可能的话)如何做到这一点

这是我当前的代码:

import requests_html as rh

session = rh.HTMLSession()
r = session.get("https://super.walmart.com.mx/papel-higienico/papel-higienico-petalo-rendimax-12-rollos-con-320-hojas-dobles/00750194345845")

r.html.render()
r.html.find('.main-content_rightContainer__3_cSi',first=True).text

Tags: httpscomhtmlconrhsuperwalmartmx