本文整理汇总了Python中mechanize.Browser.form['pass']方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.form['pass']方法的具体用法?Python Browser.form['pass']怎么用?Python Browser.form['pass']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mechanize.Browser
的用法示例。
在下文中一共展示了Browser.form['pass']方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_browser
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['pass'] [as 别名]
def get_browser(self):
"""
Each FAUrl object stores it's own browser instance. On the first call
it is created and if the username and password is set it will
authenticate you.
:return: mechanize.Browser instance.
:raise: FAiler.FAError if FA is down. Time to F5!
:raise: FAiler.FAAuth Your username and password failed
"""
if self._br is None:
br = Browser()
br.set_handle_robots(False)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_equiv(True)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
if self._username is not None and self._password is not None:
loginPage = 'https://www.furaffinity.net/login'
try:
br.open(loginPage)
except urllib2.HTTPError:
raise FAError("FA's down, F5 time.")
br.form = br.global_form()
br.form['name'] = self._username
br.form['pass'] = self._password
br.form.method = 'POST'
br.submit()
if br.geturl() == loginPage + '/?msg=1':
raise FAAuth('Username & Password Incorrect')
self._br = br
return self._br
示例2: check
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['pass'] [as 别名]
def check(acs):
for a in acs:
try:
a = a.rsplit()[0]
except:
pass
try:
if a:
a = a.split(':')
user = a[0]
passw = a[1]
br = Browser()
br.set_handle_gzip(True)
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
br.open('http://m.facebook.com/login.php')
br.select_form(nr=0)
br.form['email'] = user
br.form['pass'] = passw
br.submit()
if 'm.facebook.com/login.php' in br.geturl() or 'checkpoint' in br.geturl() or 'to confirm your account with Facebook.' in br.response().read():
print "Could not login with " + str(a)
else:
print "Logged in with " + user
opn = open(newfile, 'a')
opn.write(user + ":" + passw + '\n')
opn.close()
except:
print "Could not login with " + str(a)
示例3: postfb
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['pass'] [as 别名]
def postfb(args):
fbuser,fbpass = get_creds(name="postfb")
message =''
message = "Oskar is doing sysadmin work on the Trello card: \n" \
+ "*** " + args.card + " ***" + "\n" + args.url + "\n" \
+ "Status: " + args.status + "\n" + "Organization: " + "http://www.ovivo.dk"
br = Browser()
br.set_handle_robots(False)
br.addheaders = [('User-agent','Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Firefox/3.0.1')]
br.open( "https://m.facebook.com/" )
br.select_form(nr=0)
br.form['email'] = fbuser
br.form['pass'] = fbpass
br.submit()
br.open("https://m.facebook.com/upload.php?source_loc=composer&refid=7")
br.select_form(nr=0)
filepath = os.path.expanduser(os.path.join("~", "./trello2b.jpg"))
br.form.add_file(open(filepath, 'rb'), 'text/plain', 'd6sEz.jpg', nr=0, name='file1')
print br.form
br.form["caption"] = message
br.submit()
示例4: dictionary
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['pass'] [as 别名]
return dictionary
dictionary = dictionary()
# def run():
br = Browser()
br.set_handle_robots( False )
url = 'https://www.facebook.com/login/'
html = urllib2.urlopen(url)
br.open(url)
br.form = list(br.forms())[0]
br.form['email'] = '[email protected]'
br.form['pass'] = 'ItsaSunnyDay62'
req = br.submit()
html = req.read()
f = open('facebooktext.txt', 'w')
f.write(html)
f.close()
matches = re.findall(r"<p>([a-zA-Z0-9 !-)(?.,;:'\"_+= -]*)", open('facebooktext.txt', 'r').read())
os.remove('C:\Python27\mockingbird\\facebooktext.txt')
with open('facebook_dictionary.json', 'r') as fb:
fb_dictionary = json.load(fb)