gpt4 book ai didi

python : Submit a form on website using python

转载 作者:行者123 更新时间:2023-12-04 16:21:32 24 4
gpt4 key购买 nike

这是我要登录的页面的 html

<FORM NAME="form" METHOD="POST" ACTION="./memberlogin" onsubmit="this.onsubmit= function(){return false;}">


<table class='loginTbl' border='1' align="center" cellspacing='3' cellpadding='3' width='60%'>
<input type="hidden" name="hdnrequesttype" value="1" />
<thead>
<tr>
<td colspan='3' align="middle" class='loginHead'>Login</td>
</tr>
</thead>

<tbody class='loginBody'>

<tr>
<td class='loginBodyTd1' nowrap="nowrap">Employee ID</td>
<td class='loginBodyTd2'><input type='text' name='txtmemberid' id='txtmemberid' value='' class='loginTextBox' size='30' maxlength='8'/></td>
<td class='loginBodyTd3' rowspan='2'><input type="submit" class="goclearbutton" value=" Go "></td>
</tr><input type='hidden' name='txtmemberpwd' id='txtmemberpwd' value='' />

</tbody>

<tfoot>
<tr>
<td colspan='3' class='loginFoot'>
<font class='loginRed'>New Visitor?</font>

<a href="mailto:admin@libsys.co.in?subject=New Registration&body=New Registartion Request">Send</a> your registration request to library !

</td>
</tr>
</tfoot>

</table>
</form>

我对谷歌做了一些研究,发现我必须使用请求对象或 urllib 或 Mechanize 。所有这些都非常令人困惑,请告诉我最简单的方法。

最佳答案

为方便起见,我建议您使用 PhantomJS

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

phantom = webdriver.PhantomJS()

phantom.get('http://www.mypage.com.br')

form_consultation = phantom.find_element_by_id('txtmemberid')
form_consultation.send_keys('1234')
phantom.find_element_by_class_name('goclearbutton').click()

关于 python : Submit a form on website using python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34381612/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com