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/9/google-apps-script/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
从iedriverserver/browsermob代理获取数据| Python 3编码_Python_Selenium_Internet Explorer_Browsermob Proxy_Iedriverserver - Fatal编程技术网

从iedriverserver/browsermob代理获取数据| Python 3编码

从iedriverserver/browsermob代理获取数据| Python 3编码,python,selenium,internet-explorer,browsermob-proxy,iedriverserver,Python,Selenium,Internet Explorer,Browsermob Proxy,Iedriverserver,我已经为我的公司制作了一个废弃网站的脚本。在我得知selenium不是用来收集交通和性能数据的信息之前,一切或多或少都很好。这就是我了解browsermob代理的原因。我试着用它: from browsermobproxy import Server from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities dict={'port':

我已经为我的公司制作了一个废弃网站的脚本。在我得知selenium不是用来收集交通和性能数据的信息之前,一切或多或少都很好。这就是我了解browsermob代理的原因。我试着用它:

from browsermobproxy import Server
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

dict={'port':8090}
opt={'captureHeaders':True}
server=Server("C:\\[...]\\browsermob-proxy-2.1.4\\bin\\browsermob-proxy.bat",options=dict)
server.start()

cap = DesiredCapabilities().INTERNETEXPLORER
cap['platform'] = "Win7"
cap['version'] = "11"
cap['browserName'] = "internet explorer"
cap['ignoreProtectedModeSettings'] = True
cap['IntroduceInstabilityByIgnoringProtectedModeSettings'] = True
cap['nativeEvents'] = True
cap['ignoreZoomSetting'] = True
cap['requireWindowFocus'] = True
cap['INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS'] = True
cap['enablePersistentHover'] = True
cap['ie.usePerProcessProxy'] = True
cap.setdefault("nativeEvents", False)
proxy.add_to_webdriver_capabilities(cap)
proxy=server.create_proxy()
url="http://localhost/"
driver_path="C:\\[...]\\IEDriverServer.exe"
delay=5
browser=webdriver.Ie(capabilities=cap, executable_path=driver_path)

proxy.new_har("focus", options=opt)
browser.implicitly_wait(delay)
browser.maximize_window()
browser.get(url)
print(proxy.har)
我的变量cap的值为:

{'browserName': 'internet explorer', 'version': '11', 'platform': 'Win7', 'ignoreProtectedModeSettings': True, 'IntroduceInstabilityByIgnoringProtectedModeSettings': True, 'nativeEvents': True, 'ignoreZoomSetting': True, 'requireWindowFocus': True, 'INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS': True, 'enablePersistentHover': True, 'ie.usePerProcessProxy': True, 'proxy': {'proxyType': 'MANUAL', 'httpProxy': 'localhost:8103', 'sslProxy': 'localhost:8103'}}
但我得到的是:

{'log': {'version': '1.2', 'creator': {'name': 'BrowserMob Proxy', 'version': '2.1.4', 'comment': ''}, 'pages': [{'id': 'focus', 'startedDateTime': '2018-06-15T09:58:16.657+02:00', 'title': 'focus', 'pageTimings': {'comment': ''}, 'comment': ''}], 'entries': [], 'comment': ''}}
没有什么可看的。。。谁能告诉我我做错了什么

不幸的是,我被迫使用IE(实际上是11)

我正在使用:

  • Python 3.6.5
  • 硒3.12.0
  • 浏览器移动代理0.8.0
  • BMP 2.1.4

条目字段为空。所以它没有捕获任何流量。你是什么意思…?根据json的“条目”:[],“注释”:'''}。如果它被捕获,任何流量条目都有一些数据。但是我的脚本的废弃部分正在工作,我可以看到执行到最后。所以我应该选择trafic。只有数据收集失败。是的,存在流量,但BMP未捕获流量