import json import urllib import re import binascii def asciirepl(match): s = match.group() return binascii.unhexlify(s[2:]) query = 'google' p = urllib.urlopen('http://www.google.com/dictionary/json?callback=a&q='+query+'&sl=en&tl=en&restrict=pr,de&client=te') page = p.read()[2:-10]
By running it, I get this error,
shadyabhi@archlinux /tmp $ python2 define.py Traceback (most recent call last): File "define.py", line 19, in <module> data = json.loads(ascii_string) File "/usr/lib/python2.7/json/__init__.py", line 326, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode obj, end = self.scan_once(s, idx) ValueError: Expecting , delimiter: line 1 column 403 (char 403)
As far as I think, json has no errors since I got it from google server. All I did was remove hexadecimal characters. Any help would be greatly appreciated.
source share