kernelmachine / haveibeenpwned

Python interface to Have I Been Pwned API

Repository from Github https://github.comkernelmachine/haveibeenpwnedRepository from Github https://github.comkernelmachine/haveibeenpwned

JSONDecodeError when having a list of more than 1 account

ashkrishan opened this issue · comments

Hi

Using python v2.7.9

Thanks for this repo. It works great for one account. However, if I have a list of accounts - runtime throws an error. Below is the sample code tested:

from hibp import HIBP, AsyncHIBP

accounts = ["barackobama", "test@gmail.com"]

reqs = [HIBP.get_account_breaches(x) for x in accounts]

for req in reqs:
        req.execute()
        print req.response

Output prints the response correctly for the first element in the list but fails during second execution. Below is the error:

[{u'PwnCount': 530270, u'Domain': u'battlefieldheroes.com', u'IsSensitive': False, u'Name raphic locations', u'Historical passwords', u'Instant messenger identities', u'IP address u'AddedDate': u'2014-02-15T11:24:42Z', u'IsVerified': True, u'Description': u'In Februar for what was reported to be a feud between Gawker and 4Chan. Information about Gawkers 1 Traceback (most recent call last): File "accounts-array.py", line 8, in <module> req.execute() File "C:\Python27\lib\site-packages\hibp\hibp.py", line 159, in execute self.response = response.json() File "C:\Python27\lib\site-packages\requests\models.py", line 799, in json return json.loads(self.text, **kwargs) File "C:\Python27\lib\site-packages\simplejson\__init__.py", line 516, in loads return _default_decoder.decode(s) File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 374, in decode obj, end = self.raw_decode(s) File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 404, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thanks
Ash

Managed to fix it. Added delay of 1.6s and patched it locally in hibp package.