我试图在提交表单后获取登录名,但是输出显示为“ nothing”。我相信在开始和结束之间的html标签中有错误,但不确定是什么错误。请在下面提供帮助。
import config
import re
from robobrowser import RoboBrowser
br = RoboBrowser()
br.open('https://stackoverflow.com/users/login')
form = br.get_form(id="login-form")
form['Email address']=config.username
form['Password']=config.password
br.submit_form(form)
src = str(br.parsed())
start='<div class="name">'
end='</div>'
try:
result = re.search('%s(.*)%s' % (start, end), src).group(l)
print (result)
except:
pint ('nothing')
输出
nothing