browsermob-proxy
browsermob-proxy copied to clipboard
browsermob-proxy returns zero data on MacOS
I am using a MacBook Air with osX 10.13.5, prowsermob-proxy 2.1.4 (python part 0.8.0), selenium 3.13.0, firefox 61.0.1 and python 2.7.10, and I am trying to run essentially the example given on the python implementation repo here:
from browsermobproxy import Server
server = Server(path="./browsermob-proxy-2.1.4/bin/browsermob-proxy")
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")
print(proxy.har) # returns a HAR JSON blob
server.stop()
driver.quit()
However, printing the proxy.har does not see to work. I get the following error
Traceback (most recent call last):
File "example.py", line 16, in <module>
print(proxy.har) # returns a HAR JSON blob
File "/Users/adietz/Work/20_BSP/Jenkins/Invest/Browsermobproxy/venv_mac/lib/python2.7/site-packages/browsermobproxy/client.py", line 104, in har
return r.json()
File "/Users/adietz/Work/20_BSP/Jenkins/Invest/Browsermobproxy/venv_mac/lib/python2.7/site-packages/requests/models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Upon further investigation I can confirm that the returned text from the request (from browsermob-proxy) has zero length. It must be a bug in browsermob-proxy as the python implementation (the exact same code) works perfectly fine in a Linux environment (e.g. Ubuntu).
I also tried with different versions of browsermob-proxy (2.1.2, 2.1.3 and 2.1.4), but got the same error in each case.
I appreciate if that bug can be fixed...
I am facing with the same issue right now... Have you come across any solution?
Same issue here, does anyone have a workaround?
What worked for me was to downgrade java version to java11. I used jenv to install and manage multiple java versions.