【问题标题】:Chrome is closed with error ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with: 0Chrome 因错误错误关闭:network_change_notifier_win.cc(141)] WSALookupServiceBegin 失败:0
【发布时间】:2020-01-19 05:58:07
【问题描述】:

我的笔记本电脑操作系统是 windows 10。我正在使用 selenium webdriver 和 Python。当我通过脚本打开chrome浏览器时,加载网页后chrome关闭。下面是我的python代码和错误代码。

from selenium import webdriver

firfox_path = 'D:\Xampp7\htdocs\python_automation\Gecko_Driver\f_geckodriver-v0.26.0-win64\geckodriver.exe'

chrome_path = 'D:\Xampp7\htdocs\python_automation\Gecko_Driver\chromedriver_win32\chromedriver.exe'
browser = "chrome"

def open_chrome():
    driver = webdriver.Chrome(executable_path=chrome_path)
    driver.maximize_window()
    driver.get('http://seleniumhq.org/')

def open_firefox():
    driver = webdriver.Firefox(executable_path=firfox_path)
    driver.get('http://seleniumhq.org/')

if browser == "chrome":
    open_chrome()
elif browser == "firefox":
    open_firefox()

错误:

[6512:8744:0119/111722.550:ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with:0
DevTools listening on ws://127.0.0.1:63800/devtools/browser/bd82b677-7c97-47c6-9be1-5fae4ea25a9c
[13392:16912:0119/111722.621:ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with: 0

【问题讨论】:

    标签: python selenium google-chrome selenium-webdriver webdriver


    【解决方案1】:

    此错误消息...

    ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with:0
    

    ...暗示WSALookupServiceBegin() 方法在尝试了解是否存在网络连接时失败。

    这个错误在network_change_notifier_win.cc中定义如下:

    bool NetworkChangeNotifierWin::IsCurrentlyOffline() const {
    
      // TODO(eroman): We could cache this value, and only re-calculate it on
      //               network changes. For now we recompute it each time asked,
      //               since it is relatively fast (sub 1ms) and not called often.
    
      EnsureWinsockInit();
    
      // The following code was adapted from:
      // http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/net/notifier/base/win/async_network_alive_win32.cc?view=markup&pathrev=47343
      // The main difference is we only call WSALookupServiceNext once, whereas
      // the earlier code would traverse the entire list and pass LUP_FLUSHPREVIOUS
      // to skip past the large results.
    
      HANDLE ws_handle;
      WSAQUERYSET query_set = {0};
      query_set.dwSize = sizeof(WSAQUERYSET);
      query_set.dwNameSpace = NS_NLA;
      // Initiate a client query to iterate through the
      // currently connected networks.
      if (0 != WSALookupServiceBegin(&query_set, LUP_RETURN_ALL,
                     &ws_handle)) {
        LOG(ERROR) << "WSALookupServiceBegin failed with: " << WSAGetLastError();
        return false;
      }
    

    解决方案

    检查您的内部网络连接并确保它不会在短时间内发生故障。

    【讨论】:

    • 是的,我认为你是对的。但我不知道为什么互联网停止了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 2021-10-25
    • 2017-07-20
    • 2017-02-02
    • 2020-10-30
    • 1970-01-01
    相关资源
    最近更新 更多