我想登录我的网上银行账户并打印交易记录。
我正在使用一种名为Splinter的机械化替代品,因为它更易于使用且文档更清晰。
我写的代码在尝试填写密码表单时给了我一个错误。我似乎无法成功识别密码表单字段。因为它没有 "name=" 属性或 css 类属性。
这是代码:
username2 = '***'
password2 = '***'
browser2 = Browser()
browser2.visit('https://mijn.ing.nl/internetbankieren/SesamLoginServlet')
browser2.find_by_css('.firstfield').fill(username2)
browser2.find_by_id('#ewyeszipl').fill(password2)
browser2.click_link_by_text('Inloggen')
url2 = browser2.url
title2 = browser2.title
titlecheck2 = 'Mijn ING Overzicht - Mijn ING'
print "Stap 2 (Mijn ING):"
if title2 == titlecheck2:
print('Succeeded')
print 'The source is:'
print browser2.html
browser2.quit()
else:
print('Failed')
browser2.quit()
完整的追溯:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python "/Users/*/Dropbox/Python/Test environment 2.7.3/Splinter.py"
Traceback (most recent call last):
File "/Users/*/Dropbox/Python/Test environment 2.7.3/Splinter.py", line 45, in <module>
browser2.find_by_id('#ewyeszipl').fill_form(password2)
File "/Users/*/Library/Python/2.7/lib/python/site-packages/splinter/element_list.py", line 73, in __getattr__
self.__class__.__name__, name))
AttributeError: 'ElementList' object has no attribute 'fill_form'
Process finished with exit code 1