[英]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 中,则可能使用正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.