def baidu(self):
self.APP_ID='21803698'
self.API_KEY='EYAvb2oTaGa9oSNs53S2yx6v'
self.SECRET_KEY='dmgvBELGq9cMvk2uSPqwLUaLUpEng02D'
self.aip=AipOcr(self.APP_ID,self.API_KEY,self.SECRET_KEY)
def duqu(self):
with open('w2.png','rb') as fb:
img1 =fb.read()
self.baidu()
result = self.aip.basicGeneral(img1)
obj=json.dumps(result)
obj2=json.loads(obj)
pan=re.compile("\d+")
print(result)
print(str(re.findall(pan,str(obj2['words_result']))).strip('[]').strip("''"))
yzm=str(re.findall(pan,str(obj2['words_result']))).strip('[]').strip("''")
def open(self):
url='http://www.xxgame.net/account/login'
driver=webdriver.Chrome()
driver.get(url)
time.sleep(5)
driver.find_element_by_id('UserName').send_keys('13600533179')
driver.find_element_by_id('Password').send_keys('hahawangzi1')
driver.save_screenshot('window.png')
cd =driver.find_element_by_id('imgValidateCode')
print(cd.location)
left=cd.location['x']
top=cd.location['y']
right=cd.size['width']+left
height=cd.size['height']+top
im=Image.open("window.png")
img=im.crop((left,top,right,height))
img.save('w2.png')
self.duqu()
driver.find_element_by_id("LAY-user-login-vercode").send_keys(self.duqu().yzm)#这一步报错,这里无法调用yzm 也就是duqu里面的实例属性 这是为什么
driver.find_element_by_id("btnSubmit").click()
time.sleep(5)
def page(self):
cookies=self.driver.get_cookies()
jsonc=json.dumps()
|