Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL Response Decoding #14

Open
SecJesus opened this issue Apr 19, 2019 · 2 comments
Open

URL Response Decoding #14

SecJesus opened this issue Apr 19, 2019 · 2 comments

Comments

@SecJesus
Copy link

Hey Florian - I had an issue with using munin-host.py. Since using urllib.request.urlopen() at line 312 under the VT API Requests, the response is in bytes and needs to be decoded or else an error "TypeErrorL the JSON object must be str, not 'bytes'" is given.

Currently
` response = urllib.request.urlopen('%s?%s' % (URLS[cat],
urllib.parse.urlencode(parameters)), context=ctx).read()

            response_dict = json.loads(response)
            success = True

`

Fix
` response = urllib.request.urlopen('%s?%s' % (URLS[cat],
urllib.parse.urlencode(parameters)), context=ctx).read()

            response_dict = json.loads(response.decode('utf-8'))
            success = True

`

@Neo23x0
Copy link
Owner

Neo23x0 commented Apr 19, 2019

Did you use Python 2 oder 3

@SecJesus
Copy link
Author

Python3.4 in a virtualvenv. urllib.request would not work in python2.7 for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants