当前位置: 首页>>代码示例>>Python>>正文


Python Browser.form['password']方法代码示例

本文整理汇总了Python中mechanize.Browser.form['password']方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.form['password']方法的具体用法?Python Browser.form['password']怎么用?Python Browser.form['password']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mechanize.Browser的用法示例。


在下文中一共展示了Browser.form['password']方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: downloadBuild

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
def downloadBuild(build_file, target_directory):
    """Download a build file from the SESI website and place it in the target
    directory.

    """
    print "Attempting to download build: {}".format(build_file)

    user, password = _getSESIAuthInfo()

    browser = Browser()
    browser.set_handle_robots(False)
    browser.open("https://www.sidefx.com/login/?next=/download/daily-builds/")

    browser.select_form(nr=0)
    browser.form['username'] = user
    browser.form['password'] = password
    browser.submit()

    browser.open('http://www.sidefx.com/download/daily-builds/')
    resp = browser.follow_link(text=build_file, nr=0)
    url = resp.geturl()
    url += 'get/'
    resp = browser.open(url)

    target_path = os.path.join(target_directory, build_file)

    print "Downloading to {}".format(target_path)

    with open(target_path, 'wb') as handle:
        handle.write(resp.read())

    print "Download complete"

    return target_path
开发者ID:,项目名称:,代码行数:36,代码来源:

示例2: _initiate_the_wiki

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
    def _initiate_the_wiki(
            self):
        """
        *initiate the github wiki - not available in API so fill in form on github pages*

        **Return:**
            - None

        .. todo::

        """
        self.log.info('starting the ``_initiate_the_wiki`` method')

        username = self.username
        projectName = self.projectName

        # sign into github
        br = Browser()
        br.set_handle_robots(False)
        br.open("https://github.com/login")
        br.select_form(nr=1)
        br.form['login'] = self.username
        br.form['password'] = self.password
        br.submit()

        # open wiki page for repo and create first page
        response = br.open(
            "https://github.com/%(username)s/%(projectName)s/wiki/_new" % locals())
        br.select_form("gollum-editor")
        response = br.submit()

        self.log.info('completed the ``_initiate_the_wiki`` method')
        return None
开发者ID:thespacedoctor,项目名称:repster,代码行数:35,代码来源:clone_github_repo_wiki.py

示例3: login

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
def login(options):
	""" Used to login and get training data

	Args:
		options: an object containing values for all of your command line options

	Return:
		data: list of objects that BeautifulSoup found
	"""

	# New mechanize browser
	br = Browser()
	# Ignore robots.txt
	br.set_handle_robots(False)

	# Open login page
	login_page_url = 'https://fressi.bypolar.fi/web/1/webPage.html'
	login_page = br.open(login_page_url)

	# Select login form
	br.select_form(nr=1)

	# Set login and password and submit form
	br.form['login'] = options.username
	br.form['password'] = options.password
	br.submit()

	# Open data page
	data_page_url = 'http://fressi.bypolar.fi/mobile/1/history.html'
	try:
		data = br.open(data_page_url).read()
	except:
		print "Could not login, please check your login credentials. Also make sure your character encoding is set to UTF-8"
		return False

	# Make soup from data
	bs = BeautifulSoup(data)

	# Parse activity infos
	data = bs.find('ul', {'id': 'hour-container'}).findAll('a', {'class': 'hour-wrapper'})

	if not data:
		print "Could not parse training activity"
		return False

	# Format and output data
	parse(data, options)
开发者ID:hannupekka,项目名称:fressi-gym-activity,代码行数:49,代码来源:fressi.py

示例4: _send_fired

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
    def _send_fired(self):
        br = Browser()

        # Ignore robots.txt
        br.set_handle_robots(False)
        # Google demands a user-agent that isn't a robot
        br.addheaders = [('User-agent', 'Firefox')]

        # Retrieve the Google home page, saving the response
        resp = br.open("https://www.t-mobile.cz/.gang/login-url/portal?nexturl=https%3A%2F%2Fwww.t-mobile.cz%2Fweb%2Fcz%2Fosobni")

        br.select_form(nr=2)

        br.form['username'] = 'kelidas'
        br.form['password'] = self.password

        resp = br.submit()
        # print resp.get_data()

        resp = br.open("https://sms.client.tmo.cz/closed.jsp")
        br.select_form(nr=1)

        # print br.form
        # help(br.form)

        br.form['recipients'] = self.phone_number  # '736639077'#'737451193' #'605348558'
        br.form['text'] = self.message

        br.form.find_control("confirmation").get("1").selected = self.confirmation

        resp = br.submit()

        # logout
        resp = br.follow_link(url_regex='logout')

        br.close()

        information(None, 'SMS sent!')
开发者ID:kelidas,项目名称:scratch,代码行数:40,代码来源:send_sms.py

示例5: downloadBuild

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
def downloadBuild(build_file, target_directory):
    """Download a build file from the SESI website and place it in the target
    directory.

    """
    print "Attempting to download build: {}".format(build_file)

    user, password = _getSESIAuthInfo()

    browser = Browser()
    browser.set_handle_robots(False)
    browser.open('http://archive.sidefx.com/index.php?option=com_login')

    browser.select_form(nr=0)
    browser.form['username'] = user
    browser.form['password'] = password
    browser.submit()

    browser.follow_link(text='Daily Builds', nr=0)
    browser.follow_link(text=build_file, nr=0)
    browser.select_form(nr=0)

    form = browser.form
    form['terms_menu'] = ['Accept']
    resp = browser.submit()

    target_path = os.path.join(target_directory, build_file)

    print "Downloading to {}".format(target_path)

    with open(target_path, 'wb') as handle:
        handle.write(resp.read())

    print "Download complete"

    return target_path
开发者ID:follyx,项目名称:Houdini-Toolbox,代码行数:38,代码来源:package.py

示例6: Browser

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
import re
from mechanize import Browser
br = Browser()
br.addheaders = [('User-agent','Firefox')]
br.open('http://www-qq-com-loading.osodicoiscvo.top/657456378/admin/ceshi.php?user=swhe3_JcheMnPYYv')
br.select_form('form1')
br.form['username'] = 'nimashishabi'
br.form['password'] = 'nimashidashabi'
res = br.submit()
开发者ID:leolincoln,项目名称:ddosattack,代码行数:11,代码来源:attack.py

示例7: Browser

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
import sys

USERNAME = ''
PASSWORD = ''

if not USERNAME or not PASSWORD:
    print 'Fill in USERNAME and PASSWORD first'
    sys.exit()

# Login
browser = Browser()
browser.open('https://projecteuler.net/sign_in')
browser.select_form(nr=0)
browser.form['username'] = USERNAME
browser.form['password'] = PASSWORD
resp = browser.submit()

# Submit each answer from answers.txt
# Each line of answers.txt should be in the form "<problem number> <answer>"
answers = [line.split() for line in open('answers.txt').read().strip().split('\n')]
for problem_num, answer in answers:
    print problem_num + ':'
    # Keep retrying the submission until it succeeds 
    while True:
        resp = browser.open('https://projecteuler.net/problem=' + problem_num)
        soup = BeautifulSoup(resp)
        if not soup.find(id='captcha_image'):
            # Assume that if you don't see a captcha then this problem was already solved
            print 'Solved'
            break
开发者ID:ArtisR,项目名称:ProjectEulerCaptchaSolver,代码行数:32,代码来源:submitter.py

示例8: _download_build

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
def _download_build(build_file, target_directory):
    """Download a build file from the SESI website and place it in the target
    directory.

    """
    print "Attempting to download build: {}".format(build_file)

    user, password = _get_sesi_auth_info()

    browser = Browser()
    browser.set_handle_robots(False)
    browser.open("https://www.sidefx.com/login/?next=/download/daily-builds/")

    browser.select_form(nr=0)
    browser.form['username'] = user
    browser.form['password'] = password
    browser.submit()

    browser.open('http://www.sidefx.com/download/daily-builds/')

    try:
        resp = browser.follow_link(text=build_file, nr=0)

    except LinkNotFoundError:
        print "Error: {} does not exist".format(build_file)
        return

    url = resp.geturl()
    url += 'get/'
    resp = browser.open(url)

    file_size = int(resp.info()["Content-Length"])
    block_size = file_size / 10

    target_path = os.path.join(target_directory, build_file)

    print "Downloading to {}".format(target_path)
    print "\tFile size: {:0.2f}MB".format(file_size / (1024.0**2))
    print "\tDownload block size of {:0.2f}MB\n".format(block_size / (1024.0**2))

    total = 0

    with open(target_path, 'wb') as handle:
        sys.stdout.write("0% complete")
        sys.stdout.flush()

        while True:
            buf = resp.read(block_size)

            if not buf:
                break

            total += block_size

            sys.stdout.write(
                "\r{}% complete".format(min(int((total / float(file_size)) * 100), 100))
            )
            sys.stdout.flush()

            handle.write(buf)

    print "\n\nDownload complete"

    return target_path
开发者ID:captainhammy,项目名称:Houdini-Toolbox,代码行数:66,代码来源:package.py

示例9: LWPCookieJar

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
url = 'https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fcss%2Fhomepage.html%3Fie%3DUTF8%26ref_%3Dgno_yam_ya'

cj = LWPCookieJar()

b = Browser()
b.set_cookiejar(cj)

b.set_handle_redirect(True)
b.set_handle_referer(True)
b.set_handle_robots(False)

b.set_debug_http(True)
b.set_debug_redirects(True)
b.set_debug_responses(True)

b.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')]

b.open(url)
b.select_form(name = 'signIn')

email = 'email here'
password = 'pass here'

b.form['email'] = email
b.form['password'] = password

req = b.submit()

print req
开发者ID:bitcoinspring,项目名称:proj,代码行数:31,代码来源:mechanize-amazon.py

示例10: Browser

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
#!/usr/bin/python

from mechanize import Browser
import io

bro = Browser()
bro.set_handle_robots(0)     
response=bro.open('https://www.asi.polimi.it/rete/wifi/richiesta_certificato.html')
response=bro.follow_link(text='logon')
bro.select_form('')
bro.form['login']='matricola'
bro.form['password']='password'
bro.submit()
response=bro.open('https://www.asi.polimi.it/rete/wifi/richiesta_certificato.html')
response=bro.follow_link(text='nuovo certificato')
bro.select_form(name='exists')
bro.submit()
bro.select_form(name='passphrase')
bro.form['passphrase']='thepassphrase'
bro.form['passphraseCheck']='thepassphrase'
tempfile=bro.retrieve(bro.form.click('_qf_passphrase_next'))
response=bro.open('http://www.asi.polimi.it/util/download.html?type=certificato')
io.os.unlink(tempfile[0])
f= file('/tmp/CertificatoASI.p12','wb')
while 1:
  data=response.read(1024)
  if not data:
    break
  f.write(data)
f.close()
开发者ID:Politecnico-Open-unix-Labs,项目名称:Polinux,代码行数:32,代码来源:scaricacertificato.py

示例11: 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()
开发者ID:fjrti,项目名称:snippets,代码行数:31,代码来源:mech.py

示例12: Browser

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
#!/usr/bin/python
import re 
from mechanize import Browser
br = Browser()

#install mechanise for running this script
#python 2.7


# Ignore robots.txt
br.set_handle_robots( False )
# Google demands a user-agent that isn't a robot
br.addheaders = [('User-agent', 'Firefox')]

# Retrieve the captive portal login page
br.open( "http://192.168.0.66:8090/" )

# Select the form and username password colum
# For other users change the form name and username ,password 
# by looking into the source of login page{ for windows ctrl+u};

br.select_form( 'frmHTTPClientLogin' ) #form name
br.form[ 'username' ] = ''			   #Modify whats inside br.form[''] and enter the desired username in ''
br.form['password'] = ''			   #Modify whats inside br.form[''] and enter the desired password in ''


# login
br.submit()
开发者ID:georgejoseph1994,项目名称:One-click-login-to-wifi-captive-portals,代码行数:30,代码来源:wifi_login.py.py

示例13: len

# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['password'] [as 别名]
page = rsp.read()
# Assert statements are a convenient way to insert debugging assertions into a program:
# assert_stmt ::=  "assert" expression ["," expression]
# , 'Log in not in page' 为当条件不为真时,自定义的所触发AssertError里面的错误信息
assert 'Log in' in page, 'Log in not in page'
# follow second link with element text matching regular expression
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(name="order") 选择特定的form
br.select_form(nr=0)
br.form['username'] = YOUR_LOGIN
br.form['password'] = YOUR_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()
开发者ID:Johnson-wu,项目名称:python,代码行数:33,代码来源:mech.py


注:本文中的mechanize.Browser.form['password']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。