Example #1
0
def code():
    r = requests.get("http://cet-bm.neea.edu.cn/Home/VerifyCodeImg")
    pic = r.content
    with open('Ver_Img.png', 'wb') as f:
        f.write(pic)
    Ver_code = Img.ImgToText('Ver_Img.png')
    print(Ver_code)
    cookies = r.cookies['ASP.NET_SessionId'] + "分" + r.cookies['BIGipServercet_pool']
    return cookies, Ver_code
Example #2
0
user = driver.find_element_by_id("username")
user.send_keys("2017011398")
driver.find_element_by_id("password").send_keys("mcy200091")

#保存浏览器截图,并截取验证码图片
driver.get_screenshot_as_file(screenImg)
location = driver.find_element_by_id('code').location
size = driver.find_element_by_id('code').size
left = location['x'] + 190
top = location['y'] + 85
right = left + size['width'] + 30
bottom = top + size['height'] + 20
img = Image.open(screenImg).crop((left, top, right, bottom))
img.save(screenImg)
#填入验证码
code = Img.ImgToText('XXMH/code.png')
driver.find_element_by_id("verification").send_keys(code)

# code = driver.find_element_by_id("code")
# pic_url = str(code.get_attribute("src"))
# print(pic_url)
#点击登录
driver.find_element_by_xpath("//button").click()

#进入一卡通的iframe
# time.sleep(5)
# driver.switch_to.frame(0)
# driver.switch_to.frame(2)
#进入一卡通查询页面
time.sleep(2)
driver.get(