python으로 해결하는 JSONP 파싱 예시이다.



>>> import requests

>>> url = '...'

>>> jsonp = requests.get(url % 1000)

>>> jsonp.content

b'callback({"status":{

...

})' 

>>> import json

>>> pure_json = jsonp.text[jsonp.text.index('(') + 1 : jsonp.text.rindex(')')]

>>> dealers = json.loads(pure_json)

>>> dealers.keys()

dict_keys(['status'])

>>> dealers['count']

10 



Posted by '김용환'
,