Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Selenium wire在远程连接时不拦截请求_Python 3.x_Selenium_Selenoid_Seleniumwire - Fatal编程技术网

Python 3.x Selenium wire在远程连接时不拦截请求

Python 3.x Selenium wire在远程连接时不拦截请求,python-3.x,selenium,selenoid,seleniumwire,Python 3.x,Selenium,Selenoid,Seleniumwire,我在专用计算机上使用Selenoid来运行浏览器。 连接方式如下: 从seleniumwire导入webdriver chrome\u options=webdriver.ChromeOptions() chrome_选项。添加_参数('disable-infobar')) chrome_选项。添加_参数('--disable extensions') chrome_选项。添加_参数('--no sandbox') chrome_选项。添加_参数(“--忽略证书错误”) chrome_选项。添加

我在专用计算机上使用Selenoid来运行浏览器。
连接方式如下:

从seleniumwire导入webdriver
chrome\u options=webdriver.ChromeOptions()
chrome_选项。添加_参数('disable-infobar'))
chrome_选项。添加_参数('--disable extensions')
chrome_选项。添加_参数('--no sandbox')
chrome_选项。添加_参数(“--忽略证书错误”)
chrome_选项。添加_实验_选项('prefs',prefs)
能力={
“浏览器名”:“chrome”,
“硒:选项”:{
“enableVNC”:True
}
}
更新(chrome\u options.to\u capabilities())
driver=webdriver.Remote(
命令_executor='http://:4444/wd/hub',
期望的能力=能力,
seleniumwire_选项={
“自动配置”:False,
“地址”:“0.0.0.0”
}
)
连接正常,浏览器控件也可以工作,但当我想要获取请求列表时,它是空的:

driver.get('https://google.com')
打印(驱动程序请求)
# []

尝试以下修补程序:

# Go to the Google home page
driver.get('https://www.google.com')

# Access requests via the `requests` attribute
for request in driver.requests:
    if request.response:
        print(
            request.url,
            request.response.status_code,
            request.response.headers['Content-Type']
        )
您应该得到与此类似的结果:

https://www.google.com/ 200 text/html; charset=UTF-8
https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png 200 image/png
https://consent.google.com/status?continue=https://www.google.com&pc=s&timestamp=1531511954&gl=GB 204 text/html; charset=utf-8
https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png 200 image/png
https://ssl.gstatic.com/gb/images/i2_2ec824b0.png 200 image/png
https://www.google.com/gen_204?s=webaft&t=aft&atyp=csi&ei=kgRJW7DBONKTlwTK77wQ&rt=wsrt.366,aft.58,prt.58 204 text/html; charset=UTF-8
...