本文整理汇总了Python中mechanize.Browser.form["password"]方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.form["password"]方法的具体用法?Python Browser.form["password"]怎么用?Python Browser.form["password"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mechanize.Browser
的用法示例。
在下文中一共展示了Browser.form["password"]方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_fb_status
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form["password"] [as 别名]
def update_fb_status(email, password, message):
"""Takes the message and update facebook status.
"""
browser_obj = Browser()
browser_obj.open("http://lite.facebook.com/")
browser_obj.select_form(nr=0)
browser_obj.form["email"] = email
browser_obj.form["password"] = password
browser_obj.submit()
# Update status
browser_obj.select_form(nr=1)
browser_obj.form["message"] = message
browser_obj.submit()
示例2: len
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form["password"] [as 别名]
# home page
rsp = br.open("http://us.pycon.org/2011/home/")
print "\n***", rsp.geturl()
print "Confirm home page has 'Log in' link; click it"
page = rsp.read()
assert "Log in" in page, "Log in not in page"
rsp = br.follow_link(text_regex="Log in")
# login page
print "\n***", rsp.geturl()
print "Confirm at least a login form; submit invalid creds"
assert len(list(br.forms())) > 1, "no forms on this page"
br.select_form(nr=0)
br.form["username"] = "xxx" # wrong login
br.form["password"] = "xxx" # wrong passwd
rsp = br.submit()
# login page, with error
print "\n***", rsp.geturl()
print "Error due to invalid creds; resubmit w/valid creds"
assert rsp.geturl() == "http://us.pycon.org/2011/account/login/", rsp.geturl()
page = rsp.read()
err = str(BS(page).find("div", {"id": "errorMsg"}).find("ul").find("li").string)
assert err == "The username and/or password you specified are not correct.", err
br.select_form(nr=0)
br.form["username"] = YOUR_LOGIN
br.form["password"] = YOUR_PASSWD
rsp = br.submit()
# login successful, home page redirect
示例3: BeautifulSoup
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form["password"] [as 别名]
page = br.open('http://students2.iitm.ac.in:3000/boys')
br.select_form(nr=0)
soup = BeautifulSoup( page.read() )
a = set(soup.find_all('option'))
pri = []
print a
for p in mess_priority:
for k in a:
if p == k.get_text():
pri.append(k.get('value'))
print pri
br.form["username"] = ""
br.form["password"] = ""
i=0
for pris in pri:
print pris
i += 1
control = br.form.find_control("mess_registration[caterer_id_"+str(i)+"]")
for item in control.items:
if item.name == pris:
item.selected = True
#submit form
response = br.submit()
print response.read()