diff --git a/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java b/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java index 8c499d35..b56b597a 100644 --- a/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java +++ b/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java @@ -142,6 +142,9 @@ public VideoInfo result(int pageSize, int page, Object... obj) { try { // 先获取合集信息 HashMap headers = new HttpHeaders().getCommonHeaders("api.bilibili.com"); + HashMap headersRefer = new HashMap<>(headers); + headersRefer.put("Referer", "https://space.bilibili.com/"); + headersRefer.put("Origin", "https://space.bilibili.com/"); if (pageQueryResult.getVideoName() == null) { String url = "https://api.bilibili.com/x/v1/medialist/info?type=1&tid=0&biz_id=" + spaceID; Logger.println(url); @@ -162,10 +165,10 @@ public VideoInfo result(int pageSize, int page, Object... obj) { break; } } - String firstOid = position2Oid((page - 1) * pageSize + 1, headers, sortFieldParam); + String firstOid = position2Oid((page - 1) * pageSize + 1, headersRefer, sortFieldParam); if(firstOid.equals("end")) return pageQueryResult; - String lastOidPlus1 = position2Oid(page * pageSize + 1, headers, sortFieldParam); + String lastOidPlus1 = position2Oid(page * pageSize + 1, headersRefer, sortFieldParam); // 根据oid查询分页的详细信息 String urlFormat = "https://api.bilibili.com/x/v2/medialist/resource/list?type=1&oid=%s&otype=2&biz_id=%s&bvid=&with_current=%s&mobi_app=web&ps=%d&direction=false&sort_field=%d&tid=%s&desc=true"; diff --git a/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java b/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java index 306053fc..0c0c3548 100644 --- a/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java +++ b/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java @@ -90,7 +90,10 @@ protected boolean query(int page, int min, int max, Object... obj) { String url = String.format(urlFormat, spaceID, API_PMAX, params.get("tid"), page, keyword, params.get("order")); url += API.genDmImgParams(); url = API.encWbi(url); - String json = util.getContent(url, new HttpHeaders().getCommonHeaders("api.bilibili.com"), HttpCookies.globalCookiesWithFingerprint()); + HashMap headersRefer = new HttpHeaders().getCommonHeaders("api.bilibili.com"); + headersRefer.put("Referer", "https://space.bilibili.com/"); + headersRefer.put("Origin", "https://space.bilibili.com/"); + String json = util.getContent(url, headersRefer, HttpCookies.globalCookiesWithFingerprint()); Logger.println(url); Logger.println(json); JSONObject jobj = new JSONObject(json);