import urllib.request import urllib.parse import re import ssl ssl._create_default_https_context = ssl._create_unverified_context 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 def find_data(self, parameter, data): result = re.findall(parameter, data) return result if __name__ == '__main__': url = 'http://www.oppo.cn/thread/thread/index.json?page=1&limit=21&uid=46344778' html = Http().get(url) print(html)
oppo社区,学习笔记(一)
最新推荐文章于 2024-04-23 13:25:37 发布