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


Python mechanize.Browser方法代码示例

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


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

示例1: Key_Ops_HTTP

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def Key_Ops_HTTP():
	br = mechanize.Browser()
	br.set_handle_robots(False)
	br.addheaders = [('user-agent', '  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'),
	('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]

	try:
		br.open("http://127.0.0.1:8000/admin/login/?next=/admin/")
	except Exception as e:
		# print "[!]Critical, could not open page."
		# print "\n %s" % (e)
		pass
		
	br.form = list(br.forms())[0]
	br["username"] = "RansomBot"
	br["password"] = "prettyflypassw0rd"

	br.submit()
	# If log in was succesful retrieve key and post ID
	###---@---###
######################################---NOT IMPLEMENTED---###################################### 
开发者ID:NullArray,项目名称:Cypher,代码行数:23,代码来源:cyphermain.py

示例2: get_browser

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def get_browser(self):
        '''Returns a mechanize.Browser object configured with the framework's global options.'''
        br = mechanize.Browser()
        # set the user-agent header
        br.addheaders = [('User-agent', self._global_options['user-agent'])]
        # set debug options
        if self._global_options['verbosity'] >= 2:
            br.set_debug_http(True)
            br.set_debug_redirects(True)
            br.set_debug_responses(True)
        # set proxy
        if self._global_options['proxy']:
            br.set_proxies({'http': self._global_options['proxy'], 'https': self._global_options['proxy']})
        # additional settings
        br.set_handle_robots(False)
        # set timeout
        socket.setdefaulttimeout(self._global_options['timeout'])
        return br 
开发者ID:lanmaster53,项目名称:recon-ng,代码行数:20,代码来源:browser.py

示例3: wiglePrint

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def wiglePrint(username, password, netid):
    browser = mechanize.Browser()
    browser.open('https://wigle.net')
    #构造请求数据
    reqData = urllib.urlencode({'credential_0':username, 'credential_1':password})
    #请求登录
    browser.open('https://wigle.net/gps/gps/main/login', reqData)
    params = {}
    params['netid'] = netid
    reqParams = urllib.urlencode(params)
    respURL = 'https://wigle.net/gps/gps/main/confirmquery/'
    resp = browser.open(respURL, reqParams).read()
    print str(resp)
    mapLat = 'N/A'
    mapLon = 'N/A'
    rLat = re.findall(search_lat, resp)
    if rLat:
        mapLat = rLat[0].split('&')[0].split('=')[1]
    rLon = re.findall(search_lon, resp)
    if rLon:
        mapLon = rLon[0].split
    print '[-] Lat: ' + mapLat + ', Lon: ' + mapLon

#打印网络信息 
开发者ID:sunshinelyz,项目名称:python-hacker,代码行数:26,代码来源:windows_reg_net_location.py

示例4: wiglePrint

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def wiglePrint(username, password, netid):
    browser = mechanize.Browser()
    browser.open('https://wigle.net')
    #构造请求数据
    reqData = urllib.urlencode({'credential_0':username, 'credential_1':password})
    #请求登录
    browser.open('https://wigle.net/gps/gps/main/login', reqData)
    params = {}
    params['netid'] = netid
    reqParams = urllib.urlencode(params)
    respURL = 'https://wigle.net/gps/gps/main/confirmquery/'
    resp = browser.open(respURL, reqParams).read()
    print str(resp)
    mapLat = 'N/A'
    mapLon = 'N/A'
    rLat = re.findall(search_lat, resp)
    if rLat:
        mapLat = rLat[0].split('&')[0].split('=')[1]
    rLon = re.findall(search_lon, resp)
    if rLon:
        mapLon = rLon[0].split
    print '[-] Lat: ' + mapLat + ', Lon: ' + mapLon 
开发者ID:sunshinelyz,项目名称:python-hacker,代码行数:24,代码来源:windows_net_location.py

示例5: login

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def login(self,ids):
		try:
			global br
			br = mechanize.Browser()
			br.set_handle_equiv(True)
			br.set_handle_gzip(True)
			br.set_handle_redirect(True)
			br.set_handle_referer(True)
			br.set_handle_robots(False)
			br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
			br.addheaders = [('User-Agent','Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36')]
			br.open(self.u.format('/login'))
			br.select_form(nr=0)
			br.form['email']=ids.split('|')[0]
			br.form['pass']=ids.split('|')[1]
			sub=br.submit().read()
			if 'logout.php' in str(res) or 'mbasic_logout_button' in str(res):
				self.ganti(ids)
			else:
				print(f'[\033[91mFailed\033[0m] {ids}')
		except: pass 
开发者ID:KANG-NEWBIE,项目名称:s-mbf,代码行数:23,代码来源:Rpass.py

示例6: _init_browser

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def _init_browser(self):
        """
        Ovveride this method with the appropriate way to prepare a logged in
        browser.
        """
        self.browser = mechanize.Browser()
        self.browser.set_handle_robots(False)
        self.browser.open(self.server_url + "/youraccount/login")
        self.browser.select_form(nr=0)
        try:
            self.browser['nickname'] = self.user
            self.browser['password'] = self.password
        except:
            self.browser['p_un'] = self.user
            self.browser['p_pw'] = self.password
        # Set login_method to be writable
        self.browser.form.find_control('login_method').readonly = False
        self.browser['login_method'] = self.login_method
        self.browser.submit() 
开发者ID:indico,项目名称:indico-plugins,代码行数:21,代码来源:connector.py

示例7: HTTPcode

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def HTTPcode(self):
		try:
			if self.agent == True:
				br = Browser()

				UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
				header = {"User-Agent" : UserAgent}
				br.set_handle_robots(False)
				br.addheaders = [("User-agent", "Fifefox")]
				
				resp = br.open(self.target).code

			else:
				resp = u.urlopen(self.target).getcode()
	
			return(resp)
		except (u.HTTPError, u.URLError):
			return(404) 
开发者ID:fnk0c,项目名称:cangibrina,代码行数:20,代码来源:connection.py

示例8: redirect

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def redirect(self):
		try:
			if self.agent == True:
				br = Browser()

				UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
				header = {"User-Agent" : UserAgent}
				br.set_handle_robots(False)
				br.addheaders = [("User-agent", "Fifefox")]
				
				remote_url = br.open(self.target).geturl()

			else:
				remote_url = u.urlopen(self.target).geturl()

			return(remote_url)
		except Exception as e:
			print(e) 
开发者ID:fnk0c,项目名称:cangibrina,代码行数:20,代码来源:connection.py

示例9: Findsubmit

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def Findsubmit(link):
    global reqlist
    try:
        br = mechanize.Browser()  # initiating the browser
        br._factory.is_html = 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')]
        br.open(str(link), timeout=15)
        if br.forms():
            params = list(br.forms())
            for par in params:
                for p in par.controls:
                    ps = str(p)
                    # print p.name
                    if 'TextControl' in ps:
                        param = str(p.name)
                        reqstr = par.action + par.method + param
                        if reqstr not in reqlist:
                            reqlist.append(reqstr)
                            testxss(par.action, par.method, param)
    except Exception, e:
        print e
        pass 
开发者ID:Martin2877,项目名称:FindLinks,代码行数:25,代码来源:findlinks.py

示例10: __init__

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def __init__(self):
		#install browser
		self.br = mechanize.Browser()
		self.br.set_handle_equiv(True)
		self.br.set_handle_gzip(True)
		self.br.set_handle_redirect(True)
		self.br.set_handle_referer(True)
		self.br.set_handle_robots(False)
		self.br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
		self.br.addheaders =[('Connection','keep-alive'),
		('Pragma','no-cache'),
		('Cache-Control','no-cache'),
		('Origin','http://sms.payuterus.biz'),
		('Upgrade-Insecure-Requests','1'),
		('Content-Type','application/x-www-form-urlencoded'),
		('User-Agent','Opera/9.80 (Android; Opera Mini/8.0.1807/36.1609; U; en) Presto/2.12.423 Version/12.16'),
		('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3'),
		('Referer','http://sms.payuterus.biz/alpha/'),
		('Accept-Encoding','gzip, deflate'),
		('Accept-Language','id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7'),
		('Cookie','_ga=GA1.2.131924726.1560439960; PHPSESSID=jjrqqaakmfcgfgbtjt8tve5595; _gid=GA1.2.1969561921.1561024035; _gat=1')
		]
		self.u='http://sms.payuterus.biz/alpha/'
		self.banner() 
开发者ID:KANG-NEWBIE,项目名称:SpamSms,代码行数:26,代码来源:payu.py

示例11: __init__

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def __init__(self):
		self.br = mechanize.Browser()
		self.br.set_handle_equiv(True)
		self.br.set_handle_gzip(True)
		self.br.set_handle_redirect(True)
		self.br.set_handle_referer(True)
		self.br.set_handle_robots(False)
		self.br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
		self.br.addheaders =[('Connection','keep-alive'),
		('Pragma','no-cache'),
		('Cache-Control','no-cache'),
		('Origin','http://sms.payuterus.biz'),
		('Upgrade-Insecure-Requests','1'),
		('Content-Type','application/x-www-form-urlencoded'),
		('User-Agent','Mozilla/5.0 (Linux; Android 7.1.2; Redmi 4X Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.91 Mobile Safari/537.36'),
		('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3'),
		('Referer','http://sms.payuterus.biz/alpha/'),
		('Accept-Encoding','gzip, deflate'),
		('Accept-Language','id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7'),
		('Cookie','_ga=GA1.2.131924726.1560439960; PHPSESSID=jjrqqaakmfcgfgbtjt8tve5595; _gid=GA1.2.1969561921.1561024035; _gat=1')
		]
		self.u='http://sms.payuterus.biz/alpha/'
		self.tkmain() 
开发者ID:KANG-NEWBIE,项目名称:SpamSms,代码行数:25,代码来源:payugui.py

示例12: retDomains

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def retDomains(ip):
    #   find parked domains by ip from Hurricane Electric, can use other source
    #   may be duplicate with get_parked(data)
    domains = []
    try:
        url = "http://bgp.he.net/ip/" + ip + "#_dns"
        userAgent = [('User-agent','Mozilla/5.0 (X11; U; '+\
                      'Linux 2.4.2-2 i586; en-US; m18) Gecko/20010131 Netscape6/6.01')]
        browser = mechanize.Browser()
        browser.addheaders = userAgent
        page = browser.open(url)
        html = page.read()
        link_finder = re.compile('href="(.*?)"')
        links = link_finder.findall(html)
        for i in range (0, len(links)):
          if links[i].find('/dns/') == 0:
              domains.append(links[i][5:])
        return domains
    except:
        return domains 
开发者ID:maltelligence,项目名称:maltelligence,代码行数:22,代码来源:dnsutils.py

示例13: getBrowers

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def getBrowers():
    br = mechanize.Browser(history=NoHistory())
    #options
    br.set_handle_equiv(True)
    #br.set_handle_gzip(True)
    br.set_handle_redirect(True)
    br.set_handle_referer(True)
    br.set_handle_robots(False)
    cj = cookielib.LWPCookieJar()  
    br.set_cookiejar(cj)##关联cookies  
    br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
    br.set_debug_http(False)
    br.set_debug_redirects(False)
    br.set_debug_responses(False)
    br.addheaders = [("User-agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36")]
    return br 
开发者ID:taxigps,项目名称:xbmc-addons-chinese,代码行数:18,代码来源:video.py

示例14: cli

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def cli(scores, transfers):
	browser = mechanize.Browser()
	browser.set_handle_robots(False)	#Allows everything to be written
	cookies = mechanize.CookieJar()
	browser.set_cookiejar(cookies)
	browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')]
	browser.set_handle_refresh(False)	#Sometimes hangs without this
	if(scores):		#Called after score option is called
		soup = find_soup(browser,'http://www.goal.com/en-in/live-scores')	#Gets HTML of entire page
		score_box = soup.find_all('div',attrs={'class':'match-main-data'})	#Navigating to where the score is available in the page
		click.echo("\nThe scores of all matches being played currently is displayed below:")
		click.echo("--------------------------------------------------------------------")
		for i in score_box:		#To get the score of all live matches and recently done matches
			print i.text
			click.echo("--------------------------------------------------------------------")
		click.echo("\n\nNOTE: ALL THE MATCH TIMINGS ARE IN GMT\n\n")

	if(transfers):
		soup = find_soup(browser,'http://www.goal.com/en-us/transfer-rumours/1')	#Gets HTML of entire page
		rumours = soup.select(".transfer-card__desc p")
		click.echo("\nThe latest Transfer news & rumours are displayed below:")
		click.echo("--------------------------------------------------------------------")
		for i in rumours:
			print("->"+i.text)
			click.echo("--------------------------------------------------------------------") 
开发者ID:rahulkumaran,项目名称:Utlyz-CLI,代码行数:27,代码来源:football.py

示例15: cli

# 需要导入模块: import mechanize [as 别名]
# 或者: from mechanize import Browser [as 别名]
def cli(google,wiki):
	browser = mechanize.Browser()
	browser.set_handle_robots(False)	#Allows everything to be written
	cookies = mechanize.CookieJar()
	browser.set_cookiejar(cookies)
	browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')]
	browser.set_handle_refresh(False)	#Sometimes hangs without this
	if(google):
		query = raw_input("Enter the topic you want to search about: ")
		for link in search(query, tld="co.in", num=10, stop=1, pause=2):
			print link
	if(wiki):
		wiki_topic = raw_input('Enter the topic you want to read about: ')
		result = wikipedia.page(title=wiki_topic,auto_suggest=True,redirect=True, preload=False)
		wiki_content = result.content
		print wiki_content 
开发者ID:rahulkumaran,项目名称:Utlyz-CLI,代码行数:18,代码来源:searching.py


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