用分裂填充密码表单 [英] Filling a password form with Splinter
本文介绍了用分裂填充密码表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图填写两种表格并登录到我的银行网站。
我可以获取用户名填写的第一个表单,但我无法看到
以下是我使用的代码:
from splinter import浏览器
username2 ='***'
password2 ='***'
browser2 =浏览器()
browser2.visit('http://mijn.ing.nl')
browser2.find_by_css('。firstfield')。fill(username2)
browser2.find_by_id( '#easnhbcc')。fill(password2)
这是完整的回溯:
/ usr / local / bin / python2/ Users / narekaramjan / Dropbox / Python / Python 273 / Test.py
Traceback (最近一次调用最后):
在< module>文件中的/ Users / narekaramjan / Dropbox / Python / Python 273 / Test.py,第26行。
browser2.find_by_id('#easnhbcc')。fill(password2)
文件/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splinter/element_list .py,第73行,在__getattr__
self .__ class __.__ name__,name))
AttributeError:'ElementList'对象没有'fill'属性
处理完成并退出代码1
我也尝试过:
$ p>我怎样才能得到密码表单来填充?
解决方案
这里是工作代码:
来自splinter import浏览器
#定义用户名和密码
username2 ='***'
password2 ='***'
#选择浏览器(默认为Firefox)
browser2 =浏览器()
#填入url
browser2.visit( 'https://mijn.ing.nl/internetbankieren/SesamLoginServlet' )
#查找用户名表单并填写用户名
browser2.find_by_id('gebruikersnaam')。first.find_by_tag('input')。fill(username2)
#查找密码表并填写定义的密码
browser2.find_by_id('wachtwoord')。first.find_by_tag('input')。fill(password2)
#找到提交按钮并点击
browser2.find_by_css('。submit')。first.click()
#打印当前网址
打印browser2.url
#打印当前浏览器标题
打印browser2.title
打印当前html源代码
打印browser2.html
I'm trying to fill two forms and login to my banks website.
I can get the first form for the username to fill but I can't seem to get the form for the password to fill.
Here's the code I'm using:
from splinter import Browser
username2 = '***'
password2 = '***'
browser2 = Browser()
browser2.visit('http://mijn.ing.nl')
browser2.find_by_css('.firstfield').fill(username2)
browser2.find_by_id('#easnhbcc').fill(password2)
and this is the full traceback:
/usr/local/bin/python2 "/Users/narekaramjan/Dropbox/Python/Python 273/Test.py"
Traceback (most recent call last):
File "/Users/narekaramjan/Dropbox/Python/Python 273/Test.py", line 26, in <module>
browser2.find_by_id('#easnhbcc').fill(password2)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splinter/element_list.py", line 73, in __getattr__
self.__class__.__name__, name))
AttributeError: 'ElementList' object has no attribute 'fill'
Process finished with exit code 1
I have also tried:
browser2.find_by_name('easnhbcc').fill(password2)
How can I get the password form to fil?
解决方案
Here is the working code:
from splinter import Browser
# Define the username and password
username2 = '***'
password2 = '***'
# Choose the browser (default is Firefox)
browser2 = Browser()
# Fill in the url
browser2.visit('https://mijn.ing.nl/internetbankieren/SesamLoginServlet')
# Find the username form and fill it with the defined username
browser2.find_by_id('gebruikersnaam').first.find_by_tag('input').fill(username2)
# Find the password form and fill it with the defined password
browser2.find_by_id('wachtwoord').first.find_by_tag('input').fill(password2)
# Find the submit button and click
browser2.find_by_css('.submit').first.click()
# Print the current url
print browser2.url
# Print the current browser title
print browser2.title
# Print the current html source code
print browser2.html
这篇关于用分裂填充密码表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文