2

I have been trying to capture some HAR information from a website. I ran across browsermob-proxy, but I can't seem to get it to work. Below is my code:

from browsermobproxy import Server
server = Server(r'C:\Users\<username>\Desktop\browsermob-proxy-2.1.0\bin\browsermob-proxy.bat')
server.start()
proxy = server.create_proxy()

from selenium import webdriver
profile  = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)


proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob

server.stop()
driver.quit()

The path leads to the .bat file in the folder that I downloaded from the official website.

When I run it, it runs for about 60 seconds, after which I get the following error:

Traceback (most recent call last):
  File "har_file_reader.py", line 3, in <module>
    server.start()
  File "C:\python34\lib\site-packages\browsermobproxy\server.py", line 104, in start
    raise Exception("Can't connect to Browsermob-Proxy")
Exception: Can't connect to Browsermob-Proxy

Does anybody know how to fix this? I am running:

Windows 10 Python 3.4 Selenium 2.53.2 Browsermob-proxy 2.1.0

Pieter
  • 107
  • 1
  • 9

0 Answers0