# -*- coding: utf-8 -*-
import requests
import json
class DouyuCrawler:
def __init__(self):
self.api = 'https://www.douyu.com/gapi/rkc/directory'
def get_live_list(self):
params = {'cid1': 2, 'cid2': 201}
resp = requests.get(self.api, params=params)
data = resp.json()
return data['data']['rl']
if __name__ == '__main__':
crawler = DouyuCrawler()
print(crawler.get_live_list())