Selenium登录与爬取问题:undetected_chromedriver登录受阻
问题
我尝试登录tanfonline.com网站,打算用Python的Selenium库进行数据爬取,但被服务器识别为机器人。换成undetected_chromedriver库后,输入邮箱和密码却无法进入登录流程的下一界面。
代码实现
from undetected_chromedriver import Chrome from selenium import webdriver import time from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from fake_useragent import UserAgent from selenium.webdriver.chrome.service import Service #password = 'bri92#Ga' #email = 'ido.koubi@live.biu.ac.il' chrome = Chrome() chrome.get("https://www.tandfonline.com/action/showLogin?uri=%2F") time.sleep(120) chrome.find_element(By.TAG_NAME,"a").find_element(By.XPATH,'//*[@id="frmLogin"]/div[2]/ul/li/a').click() login = chrome.find_element(By.TAG_NAME,"input").find_element(By.XPATH,'//*[@id="shibboleth_search"]/div/input').click() select = chrome.find_element(By.TAG_NAME,"input").find_element(By.XPATH,'//*[@id="shibboleth_search"]/div/input').send_keys("Bar-Ilan University") action = ActionChains(chrome) action.send_keys(Keys.ENTER) chrome.get("https://www.tandfonline.com/doi/full/10.1080/17452750500283590")
内容的提问来源于stack exchange,提问作者Ido Kobi
相关产品推荐
相关产品推荐

