lightbody / browsermob-proxy

A free utility to help web developers watch and manipulate network traffic from their AJAX applications.
http://bmp.lightbody.net
Apache License 2.0
2.17k stars 659 forks source link

Problems with har on osx #864

Open Virgula0 opened 4 years ago

Virgula0 commented 4 years ago

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)
eric1932 commented 4 years ago

I have the same problem. It worked until 2 months ago and suddenly crashed on one day.

jrr997 commented 4 years ago

I got the sameproblem.anyone can help?