简体   繁体   English

如何使用python请求和BeautifulSoup在网站上的html中查找隐藏值

[英]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.

相关问题 如何使用 html “隐藏”输入找到属性 beautifulsoup python - how do I find the attribute with html "hidden" input with beautifulsoup python 如何使用 Python REQUESTS 和 BeautifulSoup 抓取基于动态 JavaScript 的网站? - How to scrape Dynamic JavaScript based website using Python REQUESTS and BeautifulSoup? 如何使用请求和 python 中的 beautifulsoup 对网站的所有页面进行分页 - How to paginate through all the pages of a website using requests and beautifulsoup in python 如何使用 python 请求获取本网站的 html? - How to get the html of this website using python requests? 使用 BeautifulSoup 在网站上查找特定值 - Using BeautifulSoup to find a specific value on a website 如何使用 BeautifulSoup 显示隐藏的 html 元素? - How to display hidden html elements using BeautifulSoup? 无法使用 Python 和 BeautifulSoup 解析网站的 html - Unable to parse html of a website using Python and BeautifulSoup 如何使用 BeautifulSoup Z23EEEB4347BDD26BFC6B7EE9A3B75 在 html 中找到特定的 json 键:值 - How to find specific json key:value in html with BeautifulSoup python 如何使用beautifulsoup在python中按类查找html标签 - How to find a html tag by class in python using beautifulsoup 如何使用Python中的BeautifulSoup查找链接并修改Html - How to find links and modify an Html using BeautifulSoup in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM