add - PushAgent XBiubiu123

This commit is contained in:
yangqiang3504
2022-09-01 16:35:18 +08:00
parent 4906cb758e
commit 5a4620f491
3 changed files with 30 additions and 146 deletions
@@ -2,13 +2,12 @@ package com.github.catvod.spider;
import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import com.github.catvod.crawler.Spider;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.utils.okhttp.OKCallBack;
import com.github.catvod.utils.okhttp.OkHttpUtil;
import okhttp3.Call;
import okhttp3.Cookie;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -24,8 +23,6 @@ import java.util.List;
public class Bili extends Spider {
protected JSONObject ext = null;
protected static String siteUrl = "https://www.bilibili.com";
protected static String sitHost = "www.bilibili.com";
@Override
public void init(Context context, String extend) {
@@ -52,47 +49,13 @@ public class Bili extends Spider {
return results.toString();
}
public static String cookie = "";
public static String getCookie(){
if(cookie.isEmpty()){
OKCallBack.OKCallBackDefault callBack = new OKCallBack.OKCallBackDefault() {
@Override
protected void onFailure(Call call, Exception e) {
}
@Override
protected void onResponse(Response response) {
}
};
OkHttpUtil.get(OkHttpUtil.defaultClient(),siteUrl,callBack);
List<Cookie> cookies = OkHttpUtil.cookieStore.get(sitHost);
cookie = TextUtils.join(";",cookies);
}
return cookie;
}
protected static HashMap<String, String> CookieHeaders() {
HashMap<String, String> headers = new HashMap<>();
headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
headers.put("Cookie", getCookie());
return headers;
}
@Override
public String homeVideoContent() {
try {
JSONArray videos = new JSONArray();
try {
String url = "https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword=窗 白噪音";
String content = OkHttpUtil.string(url, CookieHeaders());
int code = new JSONObject(content).getInt("code");
if(code != 0){
cookie = "";
content = OkHttpUtil.string(url, CookieHeaders());
}
String content = OkHttpUtil.string(url, null);
JSONObject data = new JSONObject(content).getJSONObject("data");
JSONArray RArray = data.getJSONArray("result");
for (int i = 0; i < RArray.length(); i++) {
@@ -145,12 +108,7 @@ public class Bili extends Spider {
}
}
url += "&page=" + pg;
String content = OkHttpUtil.string(url, CookieHeaders());
int code = new JSONObject(content).getInt("code");
if(code != 0){
cookie = "";
content = OkHttpUtil.string(url, CookieHeaders());
}
String content = OkHttpUtil.string(url, null);
JSONObject data = new JSONObject(content).getJSONObject("data");
JSONArray list = new JSONArray();
JSONArray RSArray = data.getJSONArray("result");