def InterfaceCookies(url,name,token): #变量 argsdata = {"filters": [], "sorts": [], "dbKey": None, "entityType": None, "page": 1, "pageSize": 20} dataurlencode = urllib.parse.urlencode(argsdata) posturl = url if name=='lihuaming': cookies = 'Kad_LoginName=' + name + ';Kad_Token=' + token else: cookies = 'k_e_m_user='******';k_e_m_token=' + token cookie_headers = {"Cookie": cookies} tokenvalue=None #定义接收服务器cookies方法 cj = cookiejar.CookieJar() opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) urllib.request.install_opener(opener) #请求接口 req = urllib.request.Request(url=url) res_data = urllib.request.urlopen(req) return res_data #保存cookies值 for c in cj: tokenvalue = c.value nowtime = Kad_Common.ObtainNowTime() Kad_Oracle_db.IFUpdateToken(tokenvalue, nowtime, name)
def LicenseAdd(driver, text): query = CommonLicense(driver) query.Create_ml() query.CreateIframeAdd_ml() query.LicenseNameAdd_ml(text) query.LicenseTypeAdd_ml() query.SupplierLicenseAdd_ml() query.EditAttrAdd_ml() query.YesAdd_ml() Kad_Common.RetrunContent(driver) query.LicenseIframe_ml() query.Confirm_ml()
def WeixinCookies(): try: driver = webdriver.Chrome() login = Kad_Login.ManageLogin() login.WeixinLogin(driver) tokenrb = driver.get_cookie(name='k_e_m_token')['value'] name = driver.get_cookie(name='k_e_m_user')['value'] nowtime = Kad_Common.ObtainNowTime() Kad_Oracle_db.UpdateToken(tokenrb, nowtime, name) except Exception as e: print(e) finally: driver.quit()
def setUp(self): self.driver = Kad_Common.BrowserDrive() self.driver.implicitly_wait(30) logins = Kad_Login.ManageLogin() logins.GspLogin(self.driver)
def setUp(self): self.driver = Kad_Common.BrowserDrive() self.driver.implicitly_wait(10) self.driver.maximize_window()