简体   繁体   English

使用 BeautifulSoup Python 从网页中提取特定的 JS 值

[英]Extract specific JS value from web page using BeautifulSoup Python

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我想从以下网页中提取一个字段: 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 ):我想要得到的值是这个( 3143 ):

在此处输入图像描述

I tried to do it, but no success, the value is JS generated.我试过了,但是没有成功,值是JS生成的。 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 ?你知道我该怎么做吗?

Check the source code of the webpage ( using Ctrl + U on the browser) and search your desired element whether they're present or not.检查网页的源代码(在浏览器上使用Ctrl + U )并搜索所需的元素是否存在。

If they are present in the page source then extract them, it could be using regex if for example, they are inside a JSON.如果它们存在于页面源中,则提取它们,例如,如果它们在 JSON 中,则可能使用正则表达式。

If not try selenium library如果不尝试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Python Beautifulsoup 从特定页面提取数据 - Extract data from a specific page using Python Beautifulsoup 使用python和BeautifulSoup从网页检索特定链接 - retrieve specific links from web page using python and BeautifulSoup BeautifulSoup + Python(从页面源代码中提取特定的 HTML 标签) - BeautifulSoup + Python (Extract Specific HTML Tags from Page Source Code) 使用 python 从网页中提取特定文本 - Extract specific text from web-page using python 使用 Python BeautifulSoup 从具有多个同名表的特定页面中提取数据表 - Extract data table from a specific page with multiple same name tables using Python BeautifulSoup 使用python中的beautifulsoup从具有更多文本内容的网页中提取数据 - Extract the data from a Web Page which has more Textual Content using beautifulsoup in python 如何在 Python 中使用 BeautifulSoup 从 html 中提取特定文本? - How to extract specific text from html using BeautifulSoup in Python? 如何使用python从网页中提取输入元素的值? - How to extract the value of an input element from a web page using python? Python:如何使用BeautifulSoup从HTML页面中提取URL? - Python: How to extract URL from HTML Page using BeautifulSoup? 如何在Python中使用BeautifulSoup从HTML页面提取表内容? - How to extract Table contents from an HTML page using BeautifulSoup in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM