Although I guess I already answered, I would like to add my little bit to this
import json import urllib2 class Website(object): def __init__(self,name): self.name = name def dump(self): self.data= urllib2.urlopen(self.name) return self.data def convJSON(self): data= json.load(self.dump()) print data domain = Website("https://example.com") domain.convJSON()
Note: the object passed to json.load () must support .read () , so urllib2.urlopen (self.name) .read () will not work. Doamin wire must be provided with a protocol in this case http
Nitigya Sharma Jan 12 '17 at 6:42 on 2017-01-12 06:42
source share