Qupans
This commit is contained in:
parent
001f56c842
commit
aabb9d7698
|
|
@ -1,6 +1,5 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
|
@ -10,7 +9,6 @@ import org.json.JSONObject;
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Util;
|
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
|
|
@ -19,42 +17,17 @@ import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class Qupans extends Cloud {
|
public class Qupans extends Cloud {
|
||||||
|
|
||||||
private static final String BASE_URL = "https://www.qupanshe.com";
|
private static final String BASE_URL = "https://www.qupanshe.com";
|
||||||
private static final String DEFAULT_COVER_URL = "https://fs-im-kefu.7moor-fs1.com/ly/4d2c3f00-7d4c-11e5-af15-41bf63ae4ea0/1743950734122/baidu.jpg";
|
private static final String DEFAULT_COVER_URL = "https://fs-im-kefu.7moor-fs1.com/ly/4d2c3f00-7d4c-11e5-af15-41bf63ae4ea0/1743950734122/baidu.jpg";
|
||||||
private static final String BAIDU_PAN_REGEX = "https?:\\/\\/(?:pan\\.)?baidu\\.com\\/(?:s\\/|share\\/link\\?)[^\\s]+";
|
|
||||||
private static final String PASSWORD_REGEX = "提取码[::]\\s*([a-zA-Z0-9]{4})";
|
|
||||||
|
|
||||||
public Qupans() {
|
private String get(String url) {
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Context context, String extend) {
|
|
||||||
try {
|
|
||||||
super.init(context, extend);
|
|
||||||
if (!TextUtils.isEmpty(extend)) {
|
|
||||||
try {
|
|
||||||
JSONObject json = new JSONObject(extend);
|
|
||||||
String customUrl = json.optString("url");
|
|
||||||
if (!TextUtils.isEmpty(customUrl)) {
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String requestWithHeaders(String url) {
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36");
|
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
|
||||||
headers.put("Referer", BASE_URL);
|
headers.put("Referer", BASE_URL);
|
||||||
return OkHttp.string(url, headers);
|
return OkHttp.string(url, headers);
|
||||||
}
|
}
|
||||||
|
|
@ -63,19 +36,15 @@ public class Qupans extends Cloud {
|
||||||
public String homeContent(boolean filter) {
|
public String homeContent(boolean filter) {
|
||||||
try {
|
try {
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
JSONArray classArray = new JSONArray();
|
JSONArray classes = new JSONArray();
|
||||||
JSONObject json = new JSONObject("{\"电影\":\"3\",\"电视剧\":\"2\",\"综艺\":\"4\",\"动漫\":\"5\",\"纪录片\":\"6\"}");
|
String[][] types = {{"电影","3"}, {"电视剧","2"}, {"综艺","4"}, {"动漫","5"}, {"纪录片","6"}};
|
||||||
Iterator<String> keys = json.keys();
|
for (String[] type : types) {
|
||||||
|
JSONObject cls = new JSONObject();
|
||||||
while (keys.hasNext()) {
|
cls.put("type_id", type[1]);
|
||||||
String key = keys.next();
|
cls.put("type_name", type[0]);
|
||||||
JSONObject category = new JSONObject();
|
classes.put(cls);
|
||||||
category.put("type_id", json.optString(key));
|
|
||||||
category.put("type_name", key);
|
|
||||||
classArray.put(category);
|
|
||||||
}
|
}
|
||||||
|
result.put("class", classes);
|
||||||
result.put("class", classArray);
|
|
||||||
return result.toString();
|
return result.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "{\"class\":[]}";
|
return "{\"class\":[]}";
|
||||||
|
|
@ -84,179 +53,140 @@ public class Qupans extends Cloud {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||||
String url = String.format("%s/forum.php?mod=forumdisplay&fid=%s&page=%s", BASE_URL, tid, pg);
|
|
||||||
String response = requestWithHeaders(url);
|
|
||||||
Document doc = Jsoup.parse(response);
|
|
||||||
List<Pair<String, String>> list = new ArrayList<>();
|
|
||||||
|
|
||||||
Elements items = doc.select("div.tit_box > a.s");
|
|
||||||
for (Element item : items) {
|
|
||||||
String title = item.text();
|
|
||||||
if (!title.contains("公告") && !title.contains("求")) {
|
|
||||||
list.add(new Pair<>(item.attr("href"), title));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject result = new JSONObject();
|
String html = get(BASE_URL + "/forum.php?mod=forumdisplay&fid=" + tid + "&page=" + pg);
|
||||||
JSONArray listArray = new JSONArray();
|
Document doc = Jsoup.parse(html);
|
||||||
for (Pair<String, String> item : list) {
|
JSONArray list = new JSONArray();
|
||||||
|
|
||||||
|
for (Element item : doc.select("div.tit_box > a.s")) {
|
||||||
|
String title = item.text();
|
||||||
|
if (title.contains("公告") || title.contains("求")) continue;
|
||||||
JSONObject vod = new JSONObject();
|
JSONObject vod = new JSONObject();
|
||||||
vod.put("vod_id", item.first);
|
vod.put("vod_id", item.attr("href"));
|
||||||
vod.put("vod_name", item.second);
|
vod.put("vod_name", title);
|
||||||
vod.put("vod_pic", DEFAULT_COVER_URL);
|
vod.put("vod_pic", DEFAULT_COVER_URL);
|
||||||
vod.put("vod_remarks", "");
|
vod.put("vod_remarks", "");
|
||||||
listArray.put(vod);
|
list.put(vod);
|
||||||
}
|
}
|
||||||
result.put("list", listArray);
|
|
||||||
result.put("page", pg);
|
return new JSONObject()
|
||||||
result.put("pagecount", "0");
|
.put("list", list)
|
||||||
result.put("total", "0");
|
.put("page", pg)
|
||||||
return result.toString();
|
.put("pagecount", "0")
|
||||||
|
.put("total", "0")
|
||||||
|
.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "{\"list\":[],\"page\":\"1\",\"pagecount\":\"0\",\"total\":\"0\"}";
|
return "{\"list\":[]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
public String detailContent(List<String> ids) {
|
||||||
String vodId = ids.get(0);
|
try {
|
||||||
String url = vodId.startsWith("http") ? vodId : BASE_URL + "/" + vodId;
|
String vodId = ids.get(0);
|
||||||
String html = requestWithHeaders(url);
|
String html = get(vodId.startsWith("http") ? vodId : BASE_URL + "/" + vodId);
|
||||||
Document doc = Jsoup.parse(html);
|
Document doc = Jsoup.parse(html);
|
||||||
|
|
||||||
Vod item = new Vod();
|
Vod vod = new Vod();
|
||||||
item.setVodId(vodId);
|
vod.setVodId(vodId);
|
||||||
|
vod.setVodName(doc.select("h1").first().text());
|
||||||
|
vod.setVodPic(DEFAULT_COVER_URL);
|
||||||
|
|
||||||
Element titleElement = doc.select("h1").first();
|
List<String> links = getLinks(doc);
|
||||||
String title = titleElement != null ? titleElement.text() : doc.title();
|
if (!links.isEmpty()) {
|
||||||
item.setVodName(title);
|
String pwd = getPwd(doc);
|
||||||
item.setVodPic(DEFAULT_COVER_URL);
|
for (int i = 0; i < links.size(); i++) {
|
||||||
|
String link = links.get(i);
|
||||||
List<String> shareLinks = extractBaiduPanLinks(doc);
|
if (!link.contains("pwd=") && !TextUtils.isEmpty(pwd)) {
|
||||||
|
links.set(i, link + "?pwd=" + pwd);
|
||||||
if (!shareLinks.isEmpty()) {
|
|
||||||
String pwd = Util.findByRegex(doc.text(), PASSWORD_REGEX, 1);
|
|
||||||
if (!TextUtils.isEmpty(pwd)) {
|
|
||||||
for (int i = 0; i < shareLinks.size(); i++) {
|
|
||||||
String link = shareLinks.get(i);
|
|
||||||
if (!link.contains("pwd=")) {
|
|
||||||
shareLinks.set(i, link + (link.contains("?") ? "&" : "?") + "pwd=" + pwd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vod.setVodPlayFrom(super.detailContentVodPlayFrom(links));
|
||||||
|
vod.setVodPlayUrl(super.detailContentVodPlayUrl(links));
|
||||||
}
|
}
|
||||||
|
|
||||||
String playFrom = super.detailContentVodPlayFrom(shareLinks);
|
return Result.string(vod);
|
||||||
String playUrl = super.detailContentVodPlayUrl(shareLinks);
|
} catch (Exception e) {
|
||||||
item.setVodPlayFrom(playFrom);
|
Vod vod = new Vod();
|
||||||
item.setVodPlayUrl(playUrl);
|
vod.setVodId(ids.get(0));
|
||||||
|
vod.setVodName("加载失败");
|
||||||
|
vod.setVodPic(DEFAULT_COVER_URL);
|
||||||
|
return Result.string(vod);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.string(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> extractBaiduPanLinks(Document doc) {
|
private List<String> getLinks(Document doc) {
|
||||||
List<String> shareLinks = new ArrayList<>();
|
List<String> links = new ArrayList<>();
|
||||||
|
// 从a标签中提取链接
|
||||||
|
Elements linksElements = doc.select("a");
|
||||||
|
for (Element linkElement : linksElements) {
|
||||||
|
String href = linkElement.attr("href");
|
||||||
|
if (href.contains(".baidu")) {
|
||||||
|
links.add(href);
|
||||||
|
break; // 只提取第一个百度网盘链接
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
for (Element link : doc.select("a")) {
|
private String getPwd(Document doc) {
|
||||||
String href = link.attr("href");
|
try {
|
||||||
if (href.contains("baidu.com") || href.contains("pan.baidu")) {
|
// 使用正则表达式模式提取密码
|
||||||
if (!href.startsWith("http")) {
|
String patternStr = "提取码:\\s*([A-Za-z0-9]{4})";
|
||||||
if (href.startsWith("/")) {
|
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(patternStr);
|
||||||
href = BASE_URL + href;
|
Element contentElement = doc.select("td.t_f").first();
|
||||||
}
|
if (contentElement != null) {
|
||||||
}
|
String text = contentElement.text();
|
||||||
if (!shareLinks.contains(href)) {
|
java.util.regex.Matcher matcher = pattern.matcher(text);
|
||||||
shareLinks.add(href);
|
if (matcher.find()) {
|
||||||
|
return matcher.group(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 忽略异常
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
for (Element content : doc.select("td.t_f, .content, .post-content")) {
|
|
||||||
String foundLink = Util.findByRegex(content.text(), BAIDU_PAN_REGEX, 0);
|
|
||||||
if (!TextUtils.isEmpty(foundLink) && !shareLinks.contains(foundLink)) {
|
|
||||||
shareLinks.add(foundLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shareLinks.isEmpty()) {
|
|
||||||
String foundLink = Util.findByRegex(doc.text(), BAIDU_PAN_REGEX, 0);
|
|
||||||
if (!TextUtils.isEmpty(foundLink) && !shareLinks.contains(foundLink)) {
|
|
||||||
shareLinks.add(foundLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return shareLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String searchContent(String key, boolean quick) {
|
public String searchContent(String key, boolean quick) {
|
||||||
return searchWithKeyword(key);
|
return searchContent(key, quick, "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String searchContent(String key, boolean quick, String pg) {
|
public String searchContent(String key, boolean quick, String pg) {
|
||||||
return searchWithKeyword(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String searchWithKeyword(String keyword) {
|
|
||||||
String url = BASE_URL + "/search.php?mod=forum";
|
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("srchuname", "");
|
|
||||||
params.put("srchfilter", "all");
|
|
||||||
params.put("srchfrom", "0");
|
|
||||||
params.put("before", "");
|
|
||||||
params.put("orderby", "lastpost");
|
|
||||||
params.put("ascdesc", "desc");
|
|
||||||
params.put("searchsubmit", "yes");
|
|
||||||
params.put("srchtxt", keyword);
|
|
||||||
|
|
||||||
String[] forumIds = {"2", "3", "4", "5", "6"};
|
|
||||||
for (int i = 0; i < forumIds.length; i++) {
|
|
||||||
params.put("srchfid[" + i + "]", forumIds[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
|
||||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36");
|
|
||||||
headers.put("content-type", "application/x-www-form-urlencoded");
|
|
||||||
headers.put("Cookie", "X_CACHE_KEY=4ea0277e01b1880d76edcdb5deaf7d38; f3ll_2132_saltkey=pbaZTtWt; f3ll_2132_lastvisit=1750900013; f3ll_2132_seccodecSKQwk6G=516.5c6d6036e45acc7725; f3ll_2132_sid=pS5p3e; f3ll_2132_ulastactivity=4e54n6SBOHeGXpFs4y2pmBVIZ99rNTklZ8bmLQzNerUezlIdu4SI; f3ll_2132_auth=b46bRtQ%2FO7ckeivggteyEs2twb%2B3HHbhT0FlBF4IlO%2BSb1ndi5elO0d7KDFhy15UqCC9nKGyGUmA9fYu8SWezxcK; f3ll_2132_sendmail=1; f3ll_2132_lastact=1752292107%09home.php%09spacecp; f3ll_2132_lastcheckfeed=3141%7C1752292107");
|
|
||||||
|
|
||||||
String response = OkHttp.post(url, params, headers).getBody();
|
|
||||||
Document doc = Jsoup.parse(response);
|
|
||||||
Elements items = doc.select("#threadlist ul li");
|
|
||||||
|
|
||||||
List<Pair<String, String>> list = new ArrayList<>();
|
|
||||||
for (Element item : items) {
|
|
||||||
Elements aElements = item.select("h3 > a");
|
|
||||||
if (!aElements.isEmpty()) {
|
|
||||||
String href = aElements.first().attr("href");
|
|
||||||
String title = aElements.first().text();
|
|
||||||
if (title != null && !title.isEmpty()) {
|
|
||||||
title = title.replaceAll("<[^>]+>", "");
|
|
||||||
}
|
|
||||||
list.add(new Pair<>(href, title));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject result = new JSONObject();
|
Map<String, String> params = new HashMap<>();
|
||||||
JSONArray listArray = new JSONArray();
|
params.put("searchsubmit", "yes");
|
||||||
for (Pair<String, String> item : list) {
|
params.put("srchtxt", key);
|
||||||
|
String[] fids = {"2", "3", "4", "5", "6"};
|
||||||
|
for (int i = 0; i < fids.length; i++) params.put("srchfid[" + i + "]", fids[i]);
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
|
||||||
|
headers.put("content-type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
String html = OkHttp.post(BASE_URL + "/search.php?mod=forum", params, headers).getBody();
|
||||||
|
Document doc = Jsoup.parse(html);
|
||||||
|
|
||||||
|
JSONArray list = new JSONArray();
|
||||||
|
for (Element item : doc.select("#threadlist ul li h3 > a")) {
|
||||||
JSONObject vod = new JSONObject();
|
JSONObject vod = new JSONObject();
|
||||||
vod.put("vod_id", item.first);
|
vod.put("vod_id", item.attr("href"));
|
||||||
vod.put("vod_name", item.second);
|
vod.put("vod_name", item.text());
|
||||||
vod.put("vod_pic", DEFAULT_COVER_URL);
|
vod.put("vod_pic", DEFAULT_COVER_URL);
|
||||||
vod.put("vod_remarks", "");
|
vod.put("vod_remarks", "");
|
||||||
listArray.put(vod);
|
list.put(vod);
|
||||||
}
|
}
|
||||||
result.put("list", listArray);
|
|
||||||
result.put("page", "1");
|
return new JSONObject()
|
||||||
result.put("pagecount", "1");
|
.put("list", list)
|
||||||
result.put("total", String.valueOf(listArray.length()));
|
.put("page", pg)
|
||||||
return result.toString();
|
.put("pagecount", "1")
|
||||||
|
.put("total", list.length())
|
||||||
|
.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "{\"list\":[],\"page\":\"1\",\"pagecount\":\"1\",\"total\":\"0\"}";
|
return "{\"list\":[]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
442e28f56e42d29e8ced7debc6e2b7d3
|
37e109189f05fae62f1b17bb8d501b82
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;442e28f56e42d29e8ced7debc6e2b7d3",
|
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;37e109189f05fae62f1b17bb8d501b82",
|
||||||
"lives": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue