admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.yeshi.buwan.util.rank;
 
import com.yeshi.buwan.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
import java.util.ArrayList;
import java.util.List;
 
public class MaoYanUtil {
 
 
    /**
     * 获取电视剧排行榜
     *
     * @return
     */
    public static List<String> getTVRank(int count) throws Exception {
        return getRank("", count);
    }
 
    public static List<String> getShowRank(int count) throws Exception {
        return getRank(2 + "", count);
    }
 
 
    private static List<String> getRank(String seriesType, int count) throws Exception {
 
        List<String> mList = new ArrayList<>();
        String url = String.format("http://piaofang.maoyan.com/dashboard/webHeatData?seriesType=%s&platformType=&showDate=2&dateType=0&rankType=0", seriesType);
        String result = HttpUtil.get(url);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("dataList").optJSONArray("list");
        for (int i = 0; i < array.size(); i++) {
            JSONObject item = array.optJSONObject(i);
            JSONObject seriesInfo = item.optJSONObject("seriesInfo");
            String name = seriesInfo.optString("name");
            mList.add(name);
        }
 
 
        if (count < mList.size()) {
            return mList.subList(0, count);
        }
 
        return mList;
    }
 
 
}