[英]How to find hidden value in html on a website using python requests and BeautifulSoup
I'm trying to figure out how to find a hidden value that is only revealed when a button is clicked on the webpage.我试图弄清楚如何找到一个隐藏值,该值仅在网页上单击按钮时才会显示。 I don't see anything in the network log that sends another get request to reveal the hidden values.
我在网络日志中没有看到任何发送另一个 get 请求以显示隐藏值的内容。 How would I get the hidden values on the webpage?
如何获取网页上的隐藏值?
Here's my code:这是我的代码:
product_page = self.url_session.get(
'https://www.finishline.com/store/product/nike-mamba-fury-basketball-shoes/prod2797512',
headers={
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'max-age=0',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': user-agent
},
params={
'styleId': f'{styleId}',
'colorId': f'{colorId}'
},
cookies={
'_abck': cookie # This gets a cookie
}
)
I am trying to reveal the "cartCatalogRefIds" value in the html.我试图在 html 中显示“cartCatalogRefIds”值。
You need to find the elent by id and after extract the value:您需要通过 id 找到 elent 并在提取值后:
from bs4 import BeautifulSoup
soup = BeautifulSoup(product_page.body)
value= soup.find(id='cartCatalogRefIds')['value']
And you have your value你有你的价值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.