fix: 无法打开专栏

This commit is contained in:
Aiden2014
2024-11-11 17:23:39 +08:00
parent 618d0f8a43
commit 92a0291fcc
2 changed files with 14 additions and 5 deletions

View File

@ -70,7 +70,7 @@ class HtmlHttp {
static Future reqReadHtml(id, dynamicType) async {
var response = await Request().get(
"https://www.bilibili.com/$dynamicType/$id/",
extra: {'ua': 'pc'},
extra: {'ua': 'pc', 'opus-goback': '1'},
);
Document rootTree = parse(response.data);
Element body = rootTree.body!;

View File

@ -197,6 +197,15 @@ class Request {
if (extra['ua'] != null) {
options.headers = {'user-agent': headerUa(type: extra['ua'])};
}
if (extra['opus-goback'] != null) {
List<Cookie> cookies = await cookieManager.cookieJar
.loadForRequest(Uri.parse(HttpString.baseUrl));
String cookieHeader = cookies
.map((cookie) => '${cookie.name}=${cookie.value}')
.join('; ');
options.headers!['cookie'] =
'$cookieHeader; opus-goback = ${extra['opus-goback']}';
}
}
options.responseType = resType;