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;
|
}
|
|
|
}
|