绕过滑块验证码登陆网站的实现
生活随笔
收集整理的這篇文章主要介紹了
绕过滑块验证码登陆网站的实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
因為有些網站登陸的時候需要經過滑塊驗證碼,這里實現了,一個繞過滑塊驗證碼的實例
from selenium import webdriver import time import random# 1.繞過滑塊驗證 option=webdriver.ChromeOptions() option.add_experimental_option('excludeSwitches', ['enable-automation']) option.add_argument('--disable-blink-features=AutomationControlled') driver=webdriver.Chrome(chrome_options=option) # 2.打開網站 url='https://www.taobao.com/' driver.get(url=url) # 3.輸入信息 driver.find_element_by_xpath('//*[@id="q"]').send_keys('健康水') time.sleep(random.randint(5,20)) # 3.2搜索 driver.find_element_by_xpath('//*[@id="J_TSearchForm"]/div[1]/button').click() # 4.登陸 # 4.1輸入賬戶密碼 # 輸入賬戶名稱 driver.find_element_by_xpath('//*[@id="fm-login-id"]').send_keys('foxconnxxx') # 輸入密碼信息 time.sleep(random.randint(5,20)) driver.find_element_by_xpath('//*[@id="fm-login-password"]').send_keys('xxxmima') # 4.2點擊登陸按鈕 driver.find_element_by_xpath('//*[@id="login-form"]/div[4]/button').click() # 如仍舊出現滑塊驗證,可以隱式等待,并在等待的這段時間手動滑動滑塊,解決繞過滑塊的問題 # driver.implicitly_wait(60) time.sleep(random.randint(5,20)) # 5 解析數據 price1=driver.find_element_by_xpath('//*[@id="mainsrp-itemlist"]/div/div/div[1]/div[1]/div[2]/div[1]/div[1]/strong').text print(price1)總結
以上是生活随笔為你收集整理的绕过滑块验证码登陆网站的实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: swal()弹出删除确认框
- 下一篇: RangerClient简介