zoukankan      html  css  js  c++  java
  • 无头模式,Windows和Linux

    ----windows

    from selenium  import webdriver

    from selenium .webdriver.common.by import By

    import ttime

    chrome_options =webdriver.ChromeOptions()

    chrome_options.add_argument('--headless')

    chrome_options.add_argument('--disable-gpu')

    chrome_options.add_argument('--window-size =1920,1050')

    driver =webdriver.Chrome(options = chrome_options)

     ----------------------------------------------------------

    linux 

    # cd  /etc/yum.repos.d/

    # vi google-chrome.repo

    [google-chrome]
    name=google-chrome
    baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
    enabled=1
    gpgcheck=1
    gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
    ————————————————
    #yum -y install google-chrome-stable --nogpgcheck
    查看版本
    # /usr/bin/google-chrome -version
    
    chromedriver 地址 http://chromedriver.storage.googleapis.com/index.html?path=83.0.4103.39/
    
    
    
    原文链接:https://blog.csdn.net/wudaoshihun/article/details/82948013

    给驱动赋权

    #mv chromedriver /usr/bin/chromedirver

    # chmod +x chromedriver

    #pip3 install selenium 

    安装 python3 https://www.cnblogs.com/scajy/p/11262622.html

    进入我的python就脚本文件

    进入 目录 
    software]# vi study.py
     # -*- coding :utf-8 -*-
    # @Author:kuai le de ping tou ge
    
    from selenium.webdriver.common.by import By
    from selenium import webdriver
    import time
    import os
    
    google_location = '/usr/bin/google-chrome'
    driver_location = '/usr/bin/chromedriver'
    
    
    options = webdriver.ChromeOptions()
    options.binary_location = google_location
    options.add_argument('--no-sandbox')
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument('--window-size=1920,1050')
    
    chromedriver = driver_location
    #os.envir["webdriver.chrome.driver"] = chromedriver
    
    driver = webdriver.Chrome(chrome_options=options,executable_path=chromedriver)
    
    driver.get('http://test-agent.hczypay.com')
    driver.get_screenshot_as_file('login.png')
    
    driver.close()

    software]# python3 study.py

    DeprecationWarning: use options instead of chrome_options 警告问题的解决 

    警告问题见url
    https://blog.csdn.net/xpt211314/article/details/103301344
  • 相关阅读:
    js获取日期周数
    PowerDesigner 生成SQL Server 注释脚本
    HTML中的      等6种空格标记
    创建Windows任务计划定时调用网页执行任务(通过Windows PowerShell的Invoke-WebRequest实现)
    提取全局应用程序集中的dll
    silverlight发布设置
    PowerDesigner 生成SQL Server 2005 注释脚本
    .net core 发布时视图Views文件夹不被打打包成.dll文件解决办法
    .net core 如何使用Senparc.Weixin 给指定的用户发送消息
    js禁止浏览器的回退事件
  • 原文地址:https://www.cnblogs.com/chevron123/p/13019894.html
Copyright © 2011-2022 走看看