import pymysql as mdbimport pycurlimport jsonclass Trida: def getPage(self, url): c = pycurl.Curl() c.setopt(pycurl.URL, url) c.setopt(pycurl.HTTPHEADER, ['Accept:']) c.setopt(pycurl.SSL_VERIFYPEER, 0) c.setopt(pycurl.FOLLOWLOCATION, 1) return c.perform() def getData(self): getContent = self.getPage('https://www.web.cz/api') array = json.loads(getContent) print(array)getTrida = Trida()getTrida.getData()
import StringIOdef getPage(self, url): c = pycurl.Curl() c.setopt(pycurl.URL, url) c.setopt(pycurl.HTTPHEADER, ['Accept:']) c.setopt(pycurl.SSL_VERIFYPEER, 0) response = StringIO.StringIO() c.setopt(pycurl.WRITEFUNCTION, response.write) c.setopt(pycurl.FOLLOWLOCATION, 1) c.perform() return response.getvalue()