I'm trying to use proxy.newHar in python but this throws an exception:
from browsermobproxy import Server
dict={'port':7070}
server = Server(path="./browsermob-proxy-2.1.4/bin/browsermob-proxy",options=dict)
server.start()
proxy = server.create_proxy()
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
profile = webdriver.ChromeOptions()
profile.add_argument('--proxy-server=%s' % (proxy.proxy))
profile.add_argument('--ignore-ssl-errors=yes')
profile.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
but I get:
Traceback (most recent call last):
File "test.py", line 17, in <module>
proxy.har # returns a HAR JSON blob
File "/usr/local/lib/python3.8/site-packages/browsermobproxy/client.py", line 104, in har
return r.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I'm trying to use proxy.newHar in python but this throws an exception:
but I get: