# 拼接 for get_cookie in get_cookies: cookies[get_cookie['name']] = get_cookie['value'] print(cookies) headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36nameAccount: 4008588180uid: 8378356736cb: JSONP_CALLBACK_10_24' } session = requests.session() captcha_content = session.get(captcha_image_url, headers=headers, cookies=cookies).content print(captcha_image_url) captcha_code = indetify(captcha_content) print("验证码的识别结果为:", captcha_code) #输入验证码 driver.find_element_by_id("vcode").send_keys(captcha_code) # time.sleep(5) driver.find_element_by_class_name("sub").click() # #获取cookie # cookies = {i["name"]:i["value"] for i in driver.get_cookies()} # print(cookies) time.sleep(3) driver.quit()
from yundama.dama import indetify driver = webdriver.Chrome() driver.get("https://www.douban.com/") driver.find_element_by_id("form_email").send_keys("*****@*****.**") driver.find_element_by_id("form_password").send_keys("zhoudawei123") # driver.find_element_by_class_name("bn-submit").click() # # time.sleep(3) # driver.find_element_by_id("password").send_keys("zhoudawei123") #获取验证码的地址 captcha_url = driver.find_element_by_id("captcha_image").get_attribute("src") resposne = requests.get(captcha_url) #图片的bytes字节数 ret = indetify(resposne.content) print("验证码的识别结果是:", ret) #驶入验证码 driver.find_element_by_id("captcha_field").send_keys(ret) #点击登录 driver.find_element_by_class_name("bn-submit").click() time.sleep(3) cookies_list = driver.get_cookies() cookie_dict = {i["name"]: i["value"] for i in cookies_list} print(cookie_dict) driver.quit()