使用美丽的python从网页中提取特定的JS值

发布于 2025-02-05 03:23:11 字数 499 浏览 2 评论 0原文

我想从下面的网页中提取一个字段:

​我想获得的值是这个(3143):

“在此处输入图像说明”

我试图做到这一点,但是没有成功,该值是生成JS的。到目前为止,这是我的代码。

page = requests.get('https://www.olx.bg/d/ad/podemnitsi-haspeli-tovarni-i-kuhnenski-asansori-motor-reduktori-CID1012-ID8pWNq.html')

soup = BeautifulSoup(page.content, 'html.parser')

您知道我该怎么做吗?

I want to extract a field from the following web page: https://www.olx.bg/d/ad/podemnitsi-haspeli-tovarni-i-kuhnenski-asansori-motor-reduktori-CID1012-ID8pWNq.html

The value that I want to get is this one ( 3143 ):

enter image description here

I tried to do it, but no success, the value is JS generated. Here is my code so far.

page = requests.get('https://www.olx.bg/d/ad/podemnitsi-haspeli-tovarni-i-kuhnenski-asansori-motor-reduktori-CID1012-ID8pWNq.html')

soup = BeautifulSoup(page.content, 'html.parser')

Do you have any idea how can I do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狼性发作 2025-02-12 03:23:12

检查网页的源代码(在浏览器上使用ctrl + u),并搜索您所需的元素是否存在。

如果它们存在于页面源中,然后提取它们,则可以使用Regex,例如,它们在JSON内部。

如果不尝试 selenium

Check the source code of the webpage ( using Ctrl + U on the browser) and search your desired element whether they're present or not.

If they are present in the page source then extract them, it could be using regex if for example, they are inside a JSON.

If not try selenium library

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文