带硒的Browsermob代理生成空输出 [英] Browsermob proxy with selenium generates empty output

查看:418
本文介绍了带硒的Browsermob代理生成空输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用硒3.0.2和browsermob代理0.7.1捕获网络数据.我得到的只是一个空的JSON.我的代码是:

I am using selenium 3.0.2 and browsermob proxy 0.7.1 to capture the network data. All I am getting is an empty JSON. My code is:

server = Server("/Users/dev/Downloads/browsermob-proxy-2.1.2/bin/browsermob-proxy")
server.start()
proxy = server.create_proxy()

if browser is None:
    profile = webdriver.FirefoxProfile()
    profile.set_preference("browser.privatebrowsing.autostart", True)

browser = webdriver.Firefox(firefox_profile=profile, proxy=proxy.selenium_proxy())
proxy.new_har("google", options={'captureHeaders': True, 'captureContent': True})

browser.get("https://google.com/")

print(proxy.har)

我得到的只是这个空的JSON

All I get is this empty JSON

{'log':{'pages':[{'id':'google','comment':'','pageTimings': {'comment':''},'startedDateTime':'2016-12-01T14:23:24.984-05:00', 'title':'google'}],'entries':[],'version':'1.2','creator': {'comment':``,'name':'BrowserMob Proxy','version':'2.1.2'}, 'comment':''}}

{'log': {'pages': [{'id': 'google', 'comment': '', 'pageTimings': {'comment': ''}, 'startedDateTime': '2016-12-01T14:23:24.984-05:00', 'title': 'google'}], 'entries': [], 'version': '1.2', 'creator': {'comment': '', 'name': 'BrowserMob Proxy', 'version': '2.1.2'}, 'comment': ''}}

推荐答案

尝试使用此cmd可能会解决您的问题:

Try this cmd maybe fix your problem:

yum install -y google-chrome-stable

yum install -y google-chrome-stable

这篇关于带硒的Browsermob代理生成空输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆