登录网站时遇到问题:
<form action="/shop//loginshop.php" method="POST">
<input type="hidden" name="weiter" value="/shop//index.php">
<fieldset>
<label for="kdnr">KDNR.</label><input type="text" id="kdnr" name="user"><br>
<label for="pwd">PASS</label><input type="password" name="pw" id="pwd" maxlength="16"><br>
<input name="login" class="login" type="submit" value="login">
</fieldset>
</form>
from robobrowser import RoboBrowser
import re
#Browse
browser = RoboBrowser(user_agent='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6')
browser.open(url)
form = browser.get_form(id='tab_login')
form['login'] = '/shop//loginshop.php'
form['user'] = 'my_user'
form['pw'] = 'my_pass'
browser.submit_form(form)
也许有人知道该怎么做。我检查了robobrowser的文档,但没有,每个例子都是id或类...... Thx
答案 0 :(得分:0)
一种选择是检查action
属性是否包含loginshop
:
import re
...
form = browser.get_form(action=re.compile(r'loginshop'))