import urllib.request import urllib.parse class Http: def get(self, url): html = urllib.request.urlopen(url).read().decode('utf-8') return html def post(self, url, data, cookie=''): data = urllib.parse.urlencode(data).encode('utf-8') req = urllib.request.Request(url, data) if cookie != None: req.add_header('cookie', cookie) res = urllib.request.urlopen(req) html = res.read().decode('utf-8') return html if __name__ == '__main__': url = 'http://www.oppo.cn/thread/thread/index.json?page=1&limit=21&uid=46344778' html = Http().get(url) print(html)