mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix: anti-crawl of 色花堂 (#4051)
This commit is contained in:
@@ -23,7 +23,30 @@ module.exports = async (ctx) => {
|
||||
const subformId = subformName in forumIdMaps ? forumIdMaps[subformName] : subformName;
|
||||
const typefilter = ctx.params.type ? `&filter=typeid&typeid=${ctx.params.type}` : '';
|
||||
const link = `${host}forum.php?mod=forumdisplay&fid=${subformId}${typefilter}`;
|
||||
const response = await got.get(link);
|
||||
const headers = {
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
};
|
||||
let c;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
headers: headers,
|
||||
hooks: {
|
||||
beforeRedirect: [
|
||||
(options, response) => {
|
||||
const cookie = response.headers['set-cookie'];
|
||||
if (cookie) {
|
||||
const cook = cookie.map((c) => c.split(';')[0]).join('; ');
|
||||
options.headers.Cookie = cook;
|
||||
c = cook;
|
||||
options.headers.Referer = response.url;
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
headers.Cookie = c;
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('#threadlisttableid tbody[id^=normalthread]')
|
||||
@@ -62,7 +85,7 @@ module.exports = async (ctx) => {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got.get(itemUrl);
|
||||
const response = await got.get(itemUrl, { headers: headers });
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const postMessage = $("td[id^='postmessage']").slice(0, 1);
|
||||
|
||||
@@ -14,7 +14,30 @@ module.exports = async (ctx) => {
|
||||
const subforumid = ctx.params.subforumid || 'hrxazp';
|
||||
|
||||
const link = `${host}${map[subforumid]}`;
|
||||
const response = await got.get(link);
|
||||
const headers = {
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
};
|
||||
let c;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
headers: headers,
|
||||
hooks: {
|
||||
beforeRedirect: [
|
||||
(options, response) => {
|
||||
const cookie = response.headers['set-cookie'];
|
||||
if (cookie) {
|
||||
const cook = cookie.map((c) => c.split(';')[0]).join('; ');
|
||||
options.headers.Cookie = cook;
|
||||
c = cook;
|
||||
options.headers.Referer = response.url;
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
headers.Cookie = c;
|
||||
const $ = cheerio.load(response.body);
|
||||
|
||||
const list = $('#threadlisttableid tbody')
|
||||
@@ -52,7 +75,7 @@ module.exports = async (ctx) => {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got.get(itemUrl);
|
||||
const response = await got.get(itemUrl, { headers: headers });
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const postMessage = $("td[id^='postmessage']").slice(0, 1);
|
||||
|
||||
Reference in New Issue
Block a user