from selenium import webdriver # 配置驱动
#驱动一定要自己下载并放在一个目录,否则会出错
option = webdriver.ChromeOptions() driver = webdriver.Chrome('/Users/wupeiqi/drivers/chromedriver', chrome_options=option) # 1. 控制浏览器打开指定页面 driver.get("https://dig.chouti.com/all/hot/recent/1") # 2. 找到登录按钮 btn_login = driver.find_element_by_xpath('//*[@id="login-link-a"]') # 3. 点击按钮 btn_login.click() # 4. 找到手机标签 input_user = driver.find_element_by_xpath('//*[@id="mobile"]') # 5. 找到密码标签 input_pwd = driver.find_element_by_xpath('//*[@id="mbpwd"]') # 6. 输入用户名 input_user.send_keys('123456789') # 7. 输入密码 input_pwd.send_keys('qaqaqaqa') # 8. 点击登录按钮 input_submit = driver.find_element_by_xpath( '//*[@id="footer-band"]/div[5]/div/div/div[1]/div[2]/div[4]/div[2]/div/span[1]') input_submit.click() print(driver.get_cookies()) # # 9. 点击跳转 # news = driver.find_element_by_xpath('//*[@id="newsContent20646261"]/div[1]/a[1]') # # news.click() # driver.execute_script("arguments[0].click();", news) # 10.管理浏览器 # driver.close()
破解路飞官网滑动验证码
peiqi老师为我们带来的精彩的讲解,
1 从__main__的主函数调用开始,先讲了图片的截取和距离的测算,