我尝试使用selenium通过pyhton自动登录到某个站点,但它会抛出http:405错误"请原谅我们的中断。关于你的浏览器的一些事情使我们认为你是一个机器人"我该怎么做才能避免它?我想看看执行是否正常检查代码是否正常工作如果我在无头模式下使用它我不能做。我错了吗?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'bucmi1@yandex.com'
passwordStr = 'pmz4'
browser = webdriver.Chrome()
browser.get(('https://www.milanuncios.com/mis-anuncios/'))
# fill in username and strike a subsequent button
username = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.ID, 'email')))
username.send_keys(usernameStr)
# wait for transition then continue to fill items
password = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.ID, 'contra')))
password.send_keys(passwordStr)
signInButton = browser.find_element_by_class_name('submit btnSend')
signInButton.click()
提前致谢。
答案 0 :(得分:0)
目前尚不清楚为什么会收到错误消息:
http: 405 error "Pardon our Interruption. something about your browser made us think you were a bot"
但我能够通过您自己的代码提供的凭据成功登录,通过隐身中的 chrome.options 添加一些小调整模式如下:
代码块:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'bucmi1@yandex.com'
passwordStr = 'pmz4'
options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument('--incognito')
browser = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
browser.get(('https://www.milanuncios.com/mis-anuncios/'))
# fill in username and strike a subsequent button
username = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'email')))
username.send_keys(usernameStr)
# wait for transition then continue to fill items
password = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'contra')))
password.send_keys(passwordStr)
signInButton = browser.find_element_by_css_selector("div.btnEnviarFrm>input.submit.btnSend[value^='INICIAR']")
signInButton.click()
浏览器快照:
答案 1 :(得分:0)
感谢您的回答!问题与我的默认配置文件文件夹有关。不知道确切是什么,因为有很多我不了解的文件。但是一旦我使用using namespace std;
void rev(stack<int>&x){
int sz=x.size(),mytop,mybottom;
mytop=x.top();
x.pop();
int tmp[sz-1],i=0;
while(!x.empty()){
mybottom=x.top();
tmp[i++]=mybottom;
x.pop();
}
stack<int> returnIt;
returnIt.push(mybottom);
for(i=0;i<=sz-3;i++){
returnIt.push(tmp[i]);
}
returnIt.push(mytop);
while(!returnIt.empty()){
int tt=returnIt.top();
x.push(tt);
returnIt.pop();
}
}
创建了一个新的
可以毫无问题地访问。