<i id='fx8R6'><tr id='fx8R6'><dt id='fx8R6'><q id='fx8R6'><span id='fx8R6'><b id='fx8R6'><form id='fx8R6'><ins id='fx8R6'></ins><ul id='fx8R6'></ul><sub id='fx8R6'></sub></form><legend id='fx8R6'></legend><bdo id='fx8R6'><pre id='fx8R6'><center id='fx8R6'></center></pre></bdo></b><th id='fx8R6'></th></span></q></dt></tr></i><div id='fx8R6'><tfoot id='fx8R6'></tfoot><dl id='fx8R6'><fieldset id='fx8R6'></fieldset></dl></div>

      <tfoot id='fx8R6'></tfoot>

      <small id='fx8R6'></small><noframes id='fx8R6'>

      • <bdo id='fx8R6'></bdo><ul id='fx8R6'></ul>
    1. <legend id='fx8R6'><style id='fx8R6'><dir id='fx8R6'><q id='fx8R6'></q></dir></style></legend>

      用美汤从表单中提取隐藏值

      Extracting hidden values from a form with beautifulsoup(用美汤从表单中提取隐藏值)
          <tbody id='O1GBK'></tbody>
        1. <legend id='O1GBK'><style id='O1GBK'><dir id='O1GBK'><q id='O1GBK'></q></dir></style></legend>

              <bdo id='O1GBK'></bdo><ul id='O1GBK'></ul>
                <i id='O1GBK'><tr id='O1GBK'><dt id='O1GBK'><q id='O1GBK'><span id='O1GBK'><b id='O1GBK'><form id='O1GBK'><ins id='O1GBK'></ins><ul id='O1GBK'></ul><sub id='O1GBK'></sub></form><legend id='O1GBK'></legend><bdo id='O1GBK'><pre id='O1GBK'><center id='O1GBK'></center></pre></bdo></b><th id='O1GBK'></th></span></q></dt></tr></i><div id='O1GBK'><tfoot id='O1GBK'></tfoot><dl id='O1GBK'><fieldset id='O1GBK'></fieldset></dl></div>
              • <small id='O1GBK'></small><noframes id='O1GBK'>

              • <tfoot id='O1GBK'></tfoot>
                本文介绍了用美汤从表单中提取隐藏值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试解析页面HTML响应,该响应如下(没有正确的HTML页面格式、头/正文.等):

                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><img src=" /sites/all/themes/iprn_bootstrap/images/ico_close.png"></button>
                        <h4 class="modal-title">Login</h4>
                    </div>
                    <div id="ajax-forms-messages"></div>
                    <div class="modal-body"><form action="/user/signin?destination=user/signin" method="post" id="user-login-form" accept-charset="UTF-8"><div><div class="form-item form-item-name form-type-textfield form-group"><input placeholder="E-mail *" class="form-control form-text required" type="text" id="edit-name" name="name" value="" size="15" maxlength="60" /> <label class="control-label element-invisible" for="edit-name">E-mail <span class="form-required" title="This field is required.">*</span></label>
                </div><div class="form-item form-item-pass form-type-password form-group"><input placeholder="Password *" class="form-control form-text required" type="password" id="edit-pass" name="pass" size="15" maxlength="128" /> <label class="control-label element-invisible" for="edit-pass">Password <span class="form-required" title="This field is required.">*</span></label>
                </div><input type="hidden" name="form_build_id" value="form-lLpMWePGycFNEi-XgTGuRW-vy2lNBld-rtTYEKX7JHk" />
                <input type="hidden" name="form_id" value="user_login_block" />
                <div class="form-actions form-wrapper form-group" id="edit-actions"><button id="login-submit-btn" type="submit" name="op" value="Log in" class="btn btn-primary form-submit icon-before"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span>
                 Log in</button>
                </div><a href="/user/password" class="forget" title="Request new password">Forgot your password?</a>
                    <div class="section white">Not registered? <a href="/user/registration" class="link-register">Register</a></div></div></form></div>
                

                我正在尝试获取";隐藏";输入的值,但在处理BeautifulSoup时遇到了困难,因为我正在尝试:

                soup.select_one('#form_build_id')['value']
                

                但是,这没有起作用。

                哪种更优雅的方法可以同时提取隐藏的&Quot;值&Quot;?

                <input type="hidden" name="form_build_id" value="form-lLpMWePGycFNEi-XgTGuRW-vy2lNBld-rtTYEKX7JHk" />
                <input type="hidden" name="form_id" value="user_login_block" />
                

                推荐答案

                只需搜索type="hidden"

                ...
                soup = BeautifulSoup(html, "html.parser")
                
                for tag in soup.find_all("input", type="hidden"):
                    print(tag["value"])
                

                输出:

                form-lLpMWePGycFNEi-XgTGuRW-vy2lNBld-rtTYEKX7JHk
                user_login_block
                

                这篇关于用美汤从表单中提取隐藏值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Split a Pandas column of lists into multiple columns(将 Pandas 的列表列拆分为多列)
                How does the @property decorator work in Python?(@property 装饰器在 Python 中是如何工作的?)
                What is the difference between old style and new style classes in Python?(Python中的旧样式类和新样式类有什么区别?)
                How to break out of multiple loops?(如何打破多个循环?)
                How to put the legend out of the plot(如何将传说从情节中剔除)
                Why is the output of my function printing out quot;Nonequot;?(为什么我的函数输出打印出“无?)
              • <small id='TAJLs'></small><noframes id='TAJLs'>

              • <legend id='TAJLs'><style id='TAJLs'><dir id='TAJLs'><q id='TAJLs'></q></dir></style></legend>
                  <tbody id='TAJLs'></tbody>

                    <bdo id='TAJLs'></bdo><ul id='TAJLs'></ul>

                      <tfoot id='TAJLs'></tfoot>

                        <i id='TAJLs'><tr id='TAJLs'><dt id='TAJLs'><q id='TAJLs'><span id='TAJLs'><b id='TAJLs'><form id='TAJLs'><ins id='TAJLs'></ins><ul id='TAJLs'></ul><sub id='TAJLs'></sub></form><legend id='TAJLs'></legend><bdo id='TAJLs'><pre id='TAJLs'><center id='TAJLs'></center></pre></bdo></b><th id='TAJLs'></th></span></q></dt></tr></i><div id='TAJLs'><tfoot id='TAJLs'></tfoot><dl id='TAJLs'><fieldset id='TAJLs'></fieldset></dl></div>