使用美丽的python从网页中提取特定的JS值
我想从下面的网页中提取一个字段:
我想获得的值是这个(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 ):
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查网页的源代码(在浏览器上使用
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