我使用selenium 3.0.2和浏览器代理0.7.1来捕获网络数据。我得到的只是一个空的JSON。我的代码是:
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
{“日志”:{‘页面’:{'id':'google',‘注释’:'',‘评论’:{‘注释’:‘},'startedDateTime':'2016-12-01T14:23:24.984-05:00',’标题‘:'google'},’条目‘:[],’版本‘:'1.2',’创建者‘:{’注释‘:’名称‘:'BrowserMob代理’,“版本”:'2.1.2'},‘注释’:‘’}
发布于 2016-12-12 15:40:14
你试过换衣服了吗
这是:
server = Server("/Users/dev/Downloads/browsermob-proxy-2.1.2/bin/browsermob-proxy") 对此:
server = Server("/Users/dev/Downloads/browsermob-proxy-2.1.2/bin/browsermob-proxy.bat")您需要在您的.bat服务器路径的末尾包含文件扩展名( BrowserMob ),这样它才能工作:)
发布于 2016-12-29 06:00:52
我怀疑这是由这个问题中相同的这个问题造成的: GeckoDriver目前不支持ChromeDriver和旧FirefoxDriver所支持的“代理”所需的功能。
在更新GeckoDriver/Marionette之前,您可以通过直接在Firefox配置文件上设置代理值来解决这个问题。配置文件上的相关代理字段是:
BrowserMob代理有一个测试,它展示了如何在Java中实现这一点。应该很容易将其转换为Python等效项,因为您已经有了一个firefox_profile对象。
发布于 2017-05-16 17:53:29
1.浏览器暴徒0.7.1不支持SSL来拦截https站点。
https://stackoverflow.com/questions/40919104
复制相似问题