1. 程式人生 > >打碼平臺-模擬登陸豆瓣網

打碼平臺-模擬登陸豆瓣網

from selenium import webdriver
import time
import requests
from yundama.dama import indetify

#實列化driver
driver=webdriver.Chrome()
driver.get("http://www.douban.com/")

driver.find_element_by_id("from_email").send_keys("[email protected]")
driver.find_element_by_id("from_password").send_keys("zhoudawei123")

#識別驗證碼
captcha_image_url=driver.find_element_by_id("captcha_img").get_attribute("src")
captcha_content=requests.get(captcha_image_url).content
captcha_code=indetify(captcha_content)
print("驗證碼的識別結果為:",captcha_code)

#輸入驗證碼
driver.find_element_by_id("captcha_field").send_keys(captcha_code)

driver.find_element_by_class_name("bn-submit").click()

#獲取cookie
cookies={i["name"]:i["value"] for i in driver.get_cookies()}
print(cookies)

time.sleep(3)
driver.quit()