Answers for "mechanize python XE #5"

0

mechanize python XE #5

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
Posted by: Guest on September-11-2021

Python Answers by Framework

Browse Popular Code Answers by Language