赞
踩
""" auth:Brussels """ import requests import time class DouYu(object): def __init__(self): self.url = 'https://www.douyu.com/gapi/rkc/directory/0_0/' self.page = 1 self.num = 1 self.artist_info = { } self.total_hot = 0 self.flag = 1 def __get_response(self): # 请求接口,返回响应 res = requests.get(self.url+str(self.page)) response = res.json() return response def __get_first_name(self): # 拿到第一页第一个的主播姓名,用来判断循环重复 url = 'https://www.douyu.com/gapi/rkc/directory/0_0/1' res = requests.get(url) response = res.json() first_name = response['data']['rl'][0]['nn'] return first_name def get_artist_info(self): first_name = self.__get_first_name() # 得到当前排名第一个主播姓名,用来判断循环结束 while DouYu.flag == 1: response = self.__get_response() self.info = response['data']['rl'] for i in range(len(self.info)): self.info = response['data']['rl'] name = self.info[i]['nn']<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。