zoukankan      html  css  js  c++  java
  • selenium无界面执行和反爬

    selenium无界面执行和反爬

    无界面执行

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    url="https://www.baidu.com"
    chrome_options=Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-gpu")
    
    chrome=webdriver.Chrome(executable_path="chromedriver",chrome_options=chrome_options)
    
    chrome.get(url)
    print(chrome.page_source)
    
    chrome.quit()
    

    规避服务端发现selenium请求的风险

    from selenium import webdriver
    #实现无可视化界面
    from selenium.webdriver.chrome.options import Options
    #实现规避检测
    from selenium.webdriver import ChromeOptions
    
    url="https://www.baidu.com"
    
    #无可视化
    chrome_options=Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-gpu")
    #规避检测
    option = ChromeOptions()
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    
    chrome=webdriver.Chrome(executable_path="chromedriver",chrome_options=chrome_options,options=option)
    
    chrome.get(url)
    print(chrome.page_source)
    
    chrome.quit()
    
  • 相关阅读:
    input type="number"
    Creating Directives that Communicate
    angular Creating a Directive that Adds Event Listeners
    angular 自定义指令 link
    cookie
    angular filter
    angular 倒计时
    angular $watch
    angular 自定义指令
    angular 依赖注入
  • 原文地址:https://www.cnblogs.com/zx125/p/11487665.html
Copyright © 2011-2022 走看看