我一直在用Chromedriver测试Selenium,我注意到有些页面可以检测到你正在使用Selenium,即使根本没有自动化.即使我只是通过Selenium和Xephyr使用chrome手动浏览我经常会得到一个页面,说明检测到可疑活动.我检查了我的用户代理和浏览器指纹,它们与普通的Chrome浏览器完全相同.
当我在普通镀铬中浏览这些网站时,一切正常,但是当我使用Selenium的时候,我已经检测到了.
从理论上讲,chromedriver和chrome应该看起来与任何网络服务器完全相同,但不知怎的,他们可以检测到它.
如果你想要一些测试代码试试这个:
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=1, size=(1600, 902))
display.start()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--profile-directory=Default')
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-plugins-discovery");
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.delete_all_cookies()
driver.set_window_size(800,800)
driver.set_window_position(0,0)
print 'arguments done'
driver.get('http://stubhub.com')
Run Code Online (Sandbox Code Playgroud)
如果您浏览stubhub,您将在一两个请求中被重定向和"阻止".我一直在研究这个,我无法弄清楚他们如何判断用户是否正在使用Selenium.
他们是如何做到的呢?
编辑更新:
我在Firefox中安装了Selenium IDE插件,当我在普通的firefox浏览器中使用附加插件访问stubhub.com时,我被禁止了.
编辑:
当我使用Fiddler来查看来回发送的HTTP请求时,我注意到"假浏览器"的请求通常在响应头中有"无缓存".
编辑:
这样的结果是否有办法检测到我在Javascript的Selenium Webdriver页面中建议无法检测何时使用webdriver.但是这个证据表明不然.
编辑:
该网站将指纹上传到他们的服务器,但我检查了使用chrome时硒的指纹与指纹相同.
编辑:
这是他们发送到服务器的指纹有效负载之一
{"appName":"Netscape","platform":"Linuxx86_64","cookies":1,"syslang":"en-US","userlang":"en-US","cpu":"","productSub":"20030107","setTimeout":1,"setInterval":1,"plugins":{"0":"ChromePDFViewer","1":"ShockwaveFlash","2":"WidevineContentDecryptionModule","3":"NativeClient","4":"ChromePDFViewer"},"mimeTypes":{"0":"application/pdf","1":"ShockwaveFlashapplication/x-shockwave-flash","2":"FutureSplashPlayerapplication/futuresplash","3":"WidevineContentDecryptionModuleapplication/x-ppapi-widevine-cdm","4":"NativeClientExecutableapplication/x-nacl","5":"PortableNativeClientExecutableapplication/x-pnacl","6":"PortableDocumentFormatapplication/x-google-chrome-pdf"},"screen":{"width":1600,"height":900,"colorDepth":24},"fonts":{"0":"monospace","1":"DejaVuSerif","2":"Georgia","3":"DejaVuSans","4":"TrebuchetMS","5":"Verdana","6":"AndaleMono","7":"DejaVuSansMono","8":"LiberationMono","9":"NimbusMonoL","10":"CourierNew","11":"Courier"}}
Run Code Online (Sandbox Code Playgroud)
它的硒和铬相同
编辑:
VPN仅供一次使用,但在加载第一页后会被检测到.很明显,正在运行一些javascript来检测Selenium.
javascript python selenium google-chrome selenium-chromedriver
我正在尝试将请求标头"Referer"设置为欺骗来自其他网站的请求.我们需要使用特定引用者的能力测试,它将特定的表单返回给用户,否则给出另一种形式.
我可以通过以下方式在恶作剧中做到这一点:
page.driver.headers = {"Referer" => referer_string}
Run Code Online (Sandbox Code Playgroud)
但我找不到selemium驱动程序的等效功能.
如何在capybara selenium驱动程序中设置请求标头?
当我尝试使用Selenium(Python)登录Chase网站时,我遇到以下错误消息:
但是,使用"人"登录工作正常.似乎当Selenium找到一个元素时会引发问题.
我错过了什么吗?我试图在stackoverflow上找到答案,但无济于事.
预期的结果是脚本将成功允许我以编程方式登录.
这是下面的代码示例:
import time
import os
from selenium import webdriver
CHASE_USER_ID = os.getenv('CHASE_USER_ID', None)
CHASE_PASSWORD = os.getenv('CHASE_PASSWORD', None)
assert CHASE_USER_ID is not None, 'Chase user id not set'
assert CHASE_PASSWORD is not None, ' Chase password not set'
def main():
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(r'./chromedriver', chrome_options=chrome_options)
try:
driver.get('https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?')
time.sleep(2)
user_element = driver.find_element_by_id('userId-input-field') # Finding an element here seems to make the login process fail
user_element.send_keys(CHASE_USER_ID)
password_element = driver.find_element_by_id('password-input-field')
password_element.send_keys(CHASE_PASSWORD)
time.sleep(2)
password_element.submit()
time.sleep(10)
finally:
driver.quit()
if …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome webdriver selenium-chromedriver
我正在尝试使用selenium和chrome在网站中自动执行一项非常基本的任务,但不知何故,网站检测到chrome由硒驱动并阻止每个请求.我怀疑该网站依赖于一个暴露的DOM变量,如/sf/answers/2933311741/来检测selenium驱动的浏览器.
我的问题是,有没有办法让navigator.webdriver标志为假?我愿意在修改之后尝试重新编译硒源,但我似乎无法在存储库中的任何地方找到NavigatorAutomationInformation源https://github.com/SeleniumHQ/selenium
任何帮助深表感谢
PS:我还从https://w3c.github.io/webdriver/#interface尝试了以下内容
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
Run Code Online (Sandbox Code Playgroud)
但它只在初始页面加载后更新属性.我认为该网站在我的脚本执行之前检测到该变量.
java selenium webdriver selenium-webdriver webdriver-w3c-spec
我有一个问题 --headlessPython Selenium for Chrome 模式。
代码
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
CHROME_DRIVER_DIR = "selenium/chromedriver"
chrome_options = webdriver.ChromeOptions()
caps = DesiredCapabilities().CHROME
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--remote-debugging-port=9222")
chrome_options.add_argument("--headless") # Runs Chrome in headless mode.
chrome_options.add_argument('--no-sandbox') # # Bypass OS security model
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(desired_capabilities=caps, executable_path=CHROME_DRIVER_DIR, options=chrome_options)
browser.get("https://www.manta.com/c/mm2956g/mashuda-contractors")
print(browser.page_source)
browser.quit()
Run Code Online (Sandbox Code Playgroud)
当我删除chrome_options.add_argument("--headless")所有工作正常时,但是--headless*有了下一个问题
Please enable cookies.
Error 1020 Ray ID: 53fd62b4087d8116 • 2019-12-04 11:19:28 UTC
Access denied
What happened?
This website is using a security service to …Run Code Online (Sandbox Code Playgroud) python selenium cloudflare selenium-chromedriver google-chrome-headless