Skip to content

"No JSON object could be decoded" #84

Open
@alex4200

Description

@alex4200

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 trying to run essentially the example given in the README:

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

Maybe this is a bug on the python implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions