Giter VIP home page Giter VIP logo

Comments (2)

Hyper-Beast avatar Hyper-Beast commented on July 21, 2024 1

我后面自己改好了,感谢大神。但是你上面这个写错了,executable_path="drivers/msedgedrive.exe" 这里的.exe是不需要的,加了会报错,正确的是executable_path="drivers/msedgedriver"

from jdbrandmember.

AntonVanke avatar AntonVanke commented on July 21, 2024

如果你是windows可将main.py下的

...
def getBrowser(headless: bool = False):
    chrome_options = webdriver.ChromeOptions()
    if headless:
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--disable-gpu')
        chrome_options.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2})
    _browser = webdriver.Chrome(executable_path=os.path.join(os.path.split(sys.argv[0])[0], "drivers/chromedriver"), options=chrome_options)
    return _browser
...

改为:

...
# 安装包
# pip install msedge-selenium-tools
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
def getBrowser(headless: bool = False):
    edge_options = EdgeOptions()
    if headless:
        edge_options.add_argument('--headless')
        edge_options.add_argument('--disable-gpu')
    _browser = Edge(executable_path="drivers/msedgedrive.exe", capabilities={}, options=edge_options)
    return _browser
...

对应的驱动请放于./drivers/
详见:
https://stackoverflow.com/questions/65171183/how-to-run-microsoft-edge-headless-with-selenium-python

Edge 在我电脑上无头模式不能很好运行,所以我改回了Chrome,你可以试试是否能正常运行

from jdbrandmember.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.