diff --git a/lib/routes/1point3acres/offer.js b/lib/routes/1point3acres/offer.js index cdcfbd586..2ea7516e0 100644 --- a/lib/routes/1point3acres/offer.js +++ b/lib/routes/1point3acres/offer.js @@ -27,8 +27,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: {}, }, }); @@ -37,8 +36,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { outname_w: school, }, @@ -53,8 +51,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planmajor: major, }, @@ -65,8 +62,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planmajor: major, outname_w: school, @@ -84,8 +80,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planyr: year, }, @@ -96,8 +91,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planyr: year, outname_w: school, @@ -112,8 +106,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planyr: year, planmajor: major, @@ -125,8 +118,7 @@ module.exports = async (ctx) => { responseBasic = await got({ method: 'post', url: url, - json: true, - data: { + json: { filters: { planyr: year, planmajor: major, diff --git a/lib/routes/afdian/dynamic.js b/lib/routes/afdian/dynamic.js index c98ad84e6..271fe1cf8 100644 --- a/lib/routes/afdian/dynamic.js +++ b/lib/routes/afdian/dynamic.js @@ -4,7 +4,7 @@ module.exports = async (ctx) => { const url_slug = ctx.params.uid.replace('@', ''); const baseUrl = 'https://afdian.net'; const userInfoRes = await got(`${baseUrl}/api/user/get-profile-by-slug`, { - query: { + searchParams: { url_slug, }, }); @@ -12,7 +12,7 @@ module.exports = async (ctx) => { const { user_id, name } = userInfo; const dynamicRes = await got(`${baseUrl}/api/post/get-list`, { - query: { + searchParams: { type: 'old', user_id, }, diff --git a/lib/routes/afdian/explore.js b/lib/routes/afdian/explore.js index beb680e29..bccd77236 100644 --- a/lib/routes/afdian/explore.js +++ b/lib/routes/afdian/explore.js @@ -31,7 +31,7 @@ module.exports = async (ctx) => { const baseUrl = 'https://afdian.net'; const link = `${baseUrl}/api/creator/list`; const res = await got(link, { - query: { + searchParams: { type, category_id: categoryMap[category], }, diff --git a/lib/routes/baijing/index.js b/lib/routes/baijing/index.js index 435f22614..c14bf1e1b 100644 --- a/lib/routes/baijing/index.js +++ b/lib/routes/baijing/index.js @@ -4,9 +4,8 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: 'http://www.baijingapp.com/api/get_more_articles/', - form: true, responseType: 'json', - body: { + form: { deviceid: 'ios', page: 1, }, diff --git a/lib/routes/bilibili/cache.js b/lib/routes/bilibili/cache.js index 8693fffc9..04a6070cc 100644 --- a/lib/routes/bilibili/cache.js +++ b/lib/routes/bilibili/cache.js @@ -13,8 +13,7 @@ module.exports = { headers: { Referer: `https://space.bilibili.com/${uid}/`, }, - form: true, - data: { + form: { mid: uid, }, }); diff --git a/lib/routes/bing/index.js b/lib/routes/bing/index.js index bfcec13f5..cf69bda81 100644 --- a/lib/routes/bing/index.js +++ b/lib/routes/bing/index.js @@ -1,16 +1,17 @@ const got = require('@/utils/got'); +const queryString = require('query-string'); module.exports = async (ctx) => { const response = await got({ method: 'get', - baseUrl: 'https://cn.bing.com', - url: '/HPImageArchive.aspx', - params: { + prefixUrl: 'https://cn.bing.com', + url: 'HPImageArchive.aspx', + searchParams: queryString.stringify({ format: 'js', idx: 0, n: 7, mkt: 'zh-CN', - }, + }), }); const data = response.data; ctx.state.data = { diff --git a/lib/routes/clickme/index.js b/lib/routes/clickme/index.js index ac35aff05..3ca742b88 100644 --- a/lib/routes/clickme/index.js +++ b/lib/routes/clickme/index.js @@ -13,9 +13,8 @@ module.exports = async (ctx) => { url: 'https://api.clickme.net/article/list?key=clickme', headers: { Referer: url, - 'Content-Type': 'application/x-www-form-urlencoded', }, - body: `articleType=${site ? 'r18' : 'article'}&subtype=${grouping}&subtypeSlug=${encodeURIComponent(name)}&device=&limit=10&page=1`, + form: `articleType=${site ? 'r18' : 'article'}&subtype=${grouping}&subtypeSlug=${encodeURIComponent(name)}&device=&limit=10&page=1`, }); const category_name = name === 'new' ? '最新' : response.data.data.items[0].categoryName[0].name; diff --git a/lib/routes/coronavirus/mogov-2019ncov.js b/lib/routes/coronavirus/mogov-2019ncov.js index b299dca3c..d7558a414 100644 --- a/lib/routes/coronavirus/mogov-2019ncov.js +++ b/lib/routes/coronavirus/mogov-2019ncov.js @@ -1,14 +1,10 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const FormData = require('form-data'); module.exports = async (ctx) => { const language = ctx.params.lang.toLowerCase(); const dataUrl = `https://www.ssm.gov.mo/apps1/apps/webpage2020/wpg/gcsnewssc_body.aspx`; - const form = new FormData(); - form.append('pg', '0'); - form.append('lang', language); const dateTextMapping = { ch: '日期 : ', @@ -19,7 +15,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: dataUrl, - data: form, + form: { + pg: '0', + lang: language, + }, }); const $ = cheerio.load(response.data); const items = $('div.col-xs-12') diff --git a/lib/routes/csrc/auditstatus.js b/lib/routes/csrc/auditstatus.js index adba1f4a5..3e8b5aab1 100644 --- a/lib/routes/csrc/auditstatus.js +++ b/lib/routes/csrc/auditstatus.js @@ -13,8 +13,7 @@ module.exports = async (ctx) => { headers: { 'User-Agent': userAgent, }, - form: true, - data: { + form: { appMatrCde: apply_id, pageNo: 1, pageSize: 10, diff --git a/lib/routes/dengekionline/new.js b/lib/routes/dengekionline/new.js index 5a7eaf072..55d397017 100644 --- a/lib/routes/dengekionline/new.js +++ b/lib/routes/dengekionline/new.js @@ -55,13 +55,13 @@ module.exports = async (ctx) => { if (info === undefined) { throw Error('不存在的类型'); } - const patch = info.patch; + const patch = info.patch.slice(1); const category = info.category; const title = `電撃オンライン - ${category}`; // 网页请求获取新闻列表 const response = await got(patch, { method: 'get', - baseUrl: host, + prefixUrl: host, }); const data = response.data; const link = response.url; @@ -76,7 +76,9 @@ module.exports = async (ctx) => { const liArr = $('li', element); const date = $('time', element).attr('datetime'); - const newLink = $(element).attr('href'); + const newLink = $(element) + .attr('href') + .slice(1); // 新闻封面 const cover = $('img', element); const category = liArr.map((index, li) => $(li).text()).get(); @@ -87,7 +89,7 @@ module.exports = async (ctx) => { // console.log(newLink); const result = await got(newLink, { method: 'get', - baseUrl: host, + prefixUrl: host, }); const $ = cheerio.load(result.data); const title = $('.gEntry_title').text(); diff --git a/lib/routes/dlsite/campaign.js b/lib/routes/dlsite/campaign.js index 4bcee55c4..cbb85b6c3 100644 --- a/lib/routes/dlsite/campaign.js +++ b/lib/routes/dlsite/campaign.js @@ -109,10 +109,10 @@ const setUrl = (info) => { for (const name in params) { if (Array.isArray(params[name])) { for (const index in params[name]) { - paramsPath += `/${name}[${index}]/${params[name][index]}`; + paramsPath += `${name}[${index}]/${params[name][index]}`; } } else { - paramsPath += `/${name}/${params[name]}`; + paramsPath += `${name}/${params[name]}`; } } return paramsPath; @@ -127,11 +127,11 @@ module.exports = async (ctx) => { if (ctx.params.free !== undefined) { info.params.is_free = 1; } - const link = host + setUrl(info); + const link = setUrl(info); const response = await got(link, { method: 'GET', - baseUrl: host, + prefixUrl: host, }); const data = response.data; const $ = cheerio.load(data); diff --git a/lib/routes/dlsite/new.js b/lib/routes/dlsite/new.js index 2ef0d7d2d..41ec5dc8d 100644 --- a/lib/routes/dlsite/new.js +++ b/lib/routes/dlsite/new.js @@ -55,11 +55,11 @@ module.exports = async (ctx) => { throw Error('不支持指定类型!'); } - const link = host + info.url; + const link = info.url.slice(1); const response = await got(link, { method: 'GET', - baseUrl: host, + prefixUrl: host, }); const data = response.data; const $ = cheerio.load(data); diff --git a/lib/routes/duozhuayu/search.js b/lib/routes/duozhuayu/search.js index 7d87e6157..102c20676 100644 --- a/lib/routes/duozhuayu/search.js +++ b/lib/routes/duozhuayu/search.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const aesjs = require('aes-js'); +const queryString = require('query-string'); module.exports = async (ctx) => { const wd = ctx.params.wd; @@ -41,10 +42,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url: 'https://www.duozhuayu.com/api/search', - params: { + searchParams: queryString.stringify({ type: 'normal', q: wd, - }, + }), headers: getCustomRequestHeaders(), }); const books = response.data.data || []; diff --git a/lib/routes/earthquake/index.js b/lib/routes/earthquake/index.js index 6f76cd1d5..a77095609 100644 --- a/lib/routes/earthquake/index.js +++ b/lib/routes/earthquake/index.js @@ -7,8 +7,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: api, - form: true, - data: { + form: { region: region, dateType: 2, magnitude: 0, diff --git a/lib/routes/eastday/sh.js b/lib/routes/eastday/sh.js index ec8f15af3..ca96c9680 100644 --- a/lib/routes/eastday/sh.js +++ b/lib/routes/eastday/sh.js @@ -8,8 +8,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: `https://apin.eastday.com/api/news/list`, - json: true, - data: { + json: { channelId: '15', currentPage: 1, pageSize: 20, diff --git a/lib/routes/eleme/open/announce.js b/lib/routes/eleme/open/announce.js index 18c762fb0..96182470b 100644 --- a/lib/routes/eleme/open/announce.js +++ b/lib/routes/eleme/open/announce.js @@ -5,8 +5,7 @@ module.exports = async (ctx) => { await got({ method: 'post', url: 'https://app-api.shop.ele.me/arena/invoke/?method=NoticeKeeperService.getBroadcastList', - json: true, - data: { + json: { id: '5CC2B32FA6F24CF78CB300DDE2F370BE|1565511577423', metas: { appName: 'Odin', diff --git a/lib/routes/geektime/column.js b/lib/routes/geektime/column.js index d01db2ce8..c3fd31e8c 100644 --- a/lib/routes/geektime/column.js +++ b/lib/routes/geektime/column.js @@ -10,8 +10,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://time.geekbang.org/', }, - json: true, - data: { + json: { cid: column_id, }, }); @@ -25,8 +24,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://time.geekbang.org/', }, - json: true, - data: { + json: { cid: column_id, }, }); diff --git a/lib/routes/geektime/news.js b/lib/routes/geektime/news.js index f3c87bbc9..53e34168b 100644 --- a/lib/routes/geektime/news.js +++ b/lib/routes/geektime/news.js @@ -10,8 +10,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://time.geekbang.org/', }, - json: true, - data: { + json: { cid: column_id, }, }); @@ -25,8 +24,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://time.geekbang.org/', }, - json: true, - data: { + json: { cid: column_id, }, }); diff --git a/lib/routes/getitfree/category.js b/lib/routes/getitfree/category.js index 9ecb18b1c..e4081c987 100644 --- a/lib/routes/getitfree/category.js +++ b/lib/routes/getitfree/category.js @@ -39,7 +39,7 @@ module.exports = async (ctx) => { item = item.concat(utils.parseListItem($, '.main-content')); } else { const res = await got(baseUrl, { - query: { + searchParams: { action: 'fa_load_postlist', paged: 1, category, diff --git a/lib/routes/github/branches.js b/lib/routes/github/branches.js index d20d6e5e4..76e35f444 100644 --- a/lib/routes/github/branches.js +++ b/lib/routes/github/branches.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const config = require('@/config').value; +const queryString = require('query-string'); module.exports = async (ctx) => { const user = ctx.params.user; @@ -11,9 +12,9 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url, - params: { + searchParams: queryString.stringify({ access_token: config.github && config.github.access_token, - }, + }), }); const data = response.data; diff --git a/lib/routes/github/file.js b/lib/routes/github/file.js index 7a1d5ccbc..27c2281f4 100644 --- a/lib/routes/github/file.js +++ b/lib/routes/github/file.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const config = require('@/config').value; +const queryString = require('query-string'); module.exports = async (ctx) => { const user = ctx.params.user; @@ -10,11 +11,11 @@ module.exports = async (ctx) => { const fileUrl = `https://github.com/${user}/${repo}/commits/${branch}/${filepath}`; const res = await got.get(`https://api.github.com/repos/${user}/${repo}/commits`, { - params: { + searchParams: queryString.stringify({ sha: branch, path: filepath, access_token: config.github && config.github.access_token, - }, + }), }); const list = res.data; const count = []; diff --git a/lib/routes/github/follower.js b/lib/routes/github/follower.js index f864b9d3e..428b3736e 100644 --- a/lib/routes/github/follower.js +++ b/lib/routes/github/follower.js @@ -16,8 +16,7 @@ module.exports = async (ctx) => { headers: { Authorization: `bearer ${config.github.access_token}`, }, - json: true, - data: { + json: { query: ` { user(login: "${user}") { diff --git a/lib/routes/github/issue.js b/lib/routes/github/issue.js index b7b4574f7..7b5b86fe7 100644 --- a/lib/routes/github/issue.js +++ b/lib/routes/github/issue.js @@ -3,6 +3,7 @@ const config = require('@/config').value; const md = require('markdown-it')({ html: true, }); +const queryString = require('query-string'); module.exports = async (ctx) => { const user = ctx.params.user; @@ -16,12 +17,12 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url, - params: { + searchParams: queryString.stringify({ state: state, labels: labels, sort: 'created', access_token: config.github && config.github.access_token, - }, + }), }); const data = response.data; diff --git a/lib/routes/github/pulls.js b/lib/routes/github/pulls.js index 7a965a41a..1ac83c14a 100644 --- a/lib/routes/github/pulls.js +++ b/lib/routes/github/pulls.js @@ -3,6 +3,7 @@ const config = require('@/config').value; const md = require('markdown-it')({ html: true, }); +const queryString = require('query-string'); module.exports = async (ctx) => { const user = ctx.params.user; @@ -15,10 +16,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url, - params: { + searchParams: queryString.stringify({ sort: 'created', access_token: config.github && config.github.access_token, - }, + }), }); const data = response.data; diff --git a/lib/routes/github/repos.js b/lib/routes/github/repos.js index a33bb7dba..20e2b5ae6 100644 --- a/lib/routes/github/repos.js +++ b/lib/routes/github/repos.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const config = require('@/config').value; +const queryString = require('query-string'); module.exports = async (ctx) => { const user = ctx.params.user; @@ -7,10 +8,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url: `https://api.github.com/users/${user}/repos`, - params: { + searchParams: queryString.stringify({ sort: 'created', access_token: config.github && config.github.access_token, - }, + }), }); const data = response.data; ctx.state.data = { diff --git a/lib/routes/github/star.js b/lib/routes/github/star.js index 1c7c39441..6610bd3b7 100644 --- a/lib/routes/github/star.js +++ b/lib/routes/github/star.js @@ -17,8 +17,7 @@ module.exports = async (ctx) => { headers: { Authorization: `bearer ${config.github.access_token}`, }, - json: true, - data: { + json: { query: ` { repository(owner: "${user}", name: "${repo}") { diff --git a/lib/routes/github/starred_repos.js b/lib/routes/github/starred_repos.js index 9f0e379de..92e602ff1 100644 --- a/lib/routes/github/starred_repos.js +++ b/lib/routes/github/starred_repos.js @@ -16,8 +16,7 @@ module.exports = async (ctx) => { headers: { Authorization: `bearer ${config.github.access_token}`, }, - json: true, - data: { + json: { query: ` { user(login: "${user}") { diff --git a/lib/routes/gov/zhengce/govall.js b/lib/routes/gov/zhengce/govall.js index 519444c03..4c831e736 100644 --- a/lib/routes/gov/zhengce/govall.js +++ b/lib/routes/gov/zhengce/govall.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { }); const query = `${params.toString()}&${advance}`; const res = await got.get(link, { - query: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)), + searchParams: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)), }); const $list = cheerio.load(res.data); diff --git a/lib/routes/gov/zhengce/wenjian.js b/lib/routes/gov/zhengce/wenjian.js index 8cda5837f..44e4a9a25 100644 --- a/lib/routes/gov/zhengce/wenjian.js +++ b/lib/routes/gov/zhengce/wenjian.js @@ -1,16 +1,17 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const queryString = require('query-string'); module.exports = async (ctx) => { const { pcodeJiguan } = ctx.params; const link = `http://sousuo.gov.cn/list.htm`; const res = await got.get(link, { - params: { + searchParams: queryString.stringify({ n: 20, sort: 'pubtime', t: 'paper', pcodeJiguan: pcodeJiguan ? pcodeJiguan : '', - }, + }), }); const $list = cheerio.load(res.data); diff --git a/lib/routes/gradcafe/result.js b/lib/routes/gradcafe/result.js index 3072a1b35..e3db9d684 100644 --- a/lib/routes/gradcafe/result.js +++ b/lib/routes/gradcafe/result.js @@ -1,12 +1,13 @@ const cheerio = require('cheerio'); const got = require('@/utils/got'); +const queryString = require('query-string'); const url = 'https://www.thegradcafe.com/survey/'; module.exports = async (ctx) => { const type = ctx.params.type; const res = await got.get(url, { - params: { + searchParams: queryString.stringify({ q: type, - }, + }), }); const $ = cheerio.load(res.data); const list = $('table.submission-table tbody tr'); diff --git a/lib/routes/greasyfork/scripts.js b/lib/routes/greasyfork/scripts.js index 2dc62542d..ade5478d7 100644 --- a/lib/routes/greasyfork/scripts.js +++ b/lib/routes/greasyfork/scripts.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const queryString = require('query-string'); module.exports = async (ctx) => { const language = ctx.params.language === 'all' ? 'zh-CN' : ctx.params.language; @@ -10,10 +11,10 @@ module.exports = async (ctx) => { const res = await got({ method: 'get', url: `https://greasyfork.org/${language}/scripts/${url}`, - params: { + searchParams: queryString.stringify({ filter_locale: filter_locale, sort: 'updated', - }, + }), }); const $ = cheerio.load(res.data); const list = $('.script-list').find('h2'); diff --git a/lib/routes/guet/news.js b/lib/routes/guet/news.js index fddffff13..0ee4854f7 100644 --- a/lib/routes/guet/news.js +++ b/lib/routes/guet/news.js @@ -46,10 +46,10 @@ module.exports = async (ctx) => { if (!infos[type]) { throw Error('参数不在可选范围之内'); } - const path = infos[type].path; + const path = infos[type].path.slice(1); const response = await got(path, { - baseUrl: host, + prefixUrl: host, }); const data = response.data; const $ = cheerio.load(data); diff --git a/lib/routes/hopper/index.js b/lib/routes/hopper/index.js index 818b0de34..e91a66208 100644 --- a/lib/routes/hopper/index.js +++ b/lib/routes/hopper/index.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const dayjs = require('dayjs'); +const queryString = require('query-string'); module.exports = async (ctx) => { const from = ctx.params.from.toUpperCase(); @@ -14,10 +15,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url, - params: { + searchParams: queryString.stringify({ pid: 'website', c: 'flexweb', - }, + }), }); const $ = cheerio.load(response.data); diff --git a/lib/routes/houxu/live.js b/lib/routes/houxu/live.js index 5a009ef2f..d2240c120 100644 --- a/lib/routes/houxu/live.js +++ b/lib/routes/houxu/live.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { }); const itemsRes = await got(`${baseUrl}/api/1/lives/${id}/threads`, { - query: { + searchParams: { limit: 40, }, }); diff --git a/lib/routes/hpoi/info.js b/lib/routes/hpoi/info.js index c2cd6f9d2..6d3c4f6f7 100644 --- a/lib/routes/hpoi/info.js +++ b/lib/routes/hpoi/info.js @@ -1,19 +1,16 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const FormData = require('form-data'); module.exports = async (ctx) => { const { type = 'all' } = ctx.params; const baseUrl = 'https://www.hpoi.net'; const reqUrl = `${baseUrl}/user/home/ajax`; - const formData = new FormData(); - Object.entries({ - page: 1, - type: 'info', - catType: type, - }).forEach(([key, value]) => formData.append(key, value)); const response = await got.post(reqUrl, { - body: formData, + form: { + page: 1, + type: 'info', + catType: type, + }, }); const $ = cheerio.load(response.data.data.html); diff --git a/lib/routes/icourse163/newest.js b/lib/routes/icourse163/newest.js index b1c7dd268..92385295a 100644 --- a/lib/routes/icourse163/newest.js +++ b/lib/routes/icourse163/newest.js @@ -14,8 +14,7 @@ module.exports = async (ctx) => { headers: { Cookie: `NTESSTUDYSI=${csrfKey};`, }, - form: true, - data: { + form: { categoryId: -1, type: 30, orderBy: 10, diff --git a/lib/routes/imaijia/category.js b/lib/routes/imaijia/category.js index 7c810b14e..2708f5343 100644 --- a/lib/routes/imaijia/category.js +++ b/lib/routes/imaijia/category.js @@ -11,9 +11,8 @@ module.exports = async (ctx) => { headers: { Referer: url, }, - form: true, url: api_url, - data: { + form: { pageNo: 1, catid: `${category}`, }, diff --git a/lib/routes/infoq/recommend.js b/lib/routes/infoq/recommend.js index 0a546a615..3bfed9887 100644 --- a/lib/routes/infoq/recommend.js +++ b/lib/routes/infoq/recommend.js @@ -11,8 +11,7 @@ module.exports = async (ctx) => { headers: { Referer: pageUrl, }, - json: true, - data: { + json: { size: 5, }, }); diff --git a/lib/routes/infoq/topic.js b/lib/routes/infoq/topic.js index 8c70bafa8..30ecf31d3 100644 --- a/lib/routes/infoq/topic.js +++ b/lib/routes/infoq/topic.js @@ -13,8 +13,7 @@ module.exports = async (ctx) => { headers: { Referer: pageUrl, }, - json: true, - data: { + json: { id: paramId, }, }); @@ -27,8 +26,7 @@ module.exports = async (ctx) => { headers: { Referer: pageUrl, }, - json: true, - data: { + json: { size: 5, type: type, id: paramId, diff --git a/lib/routes/infoq/utils.js b/lib/routes/infoq/utils.js index 02c98ca83..0b860588e 100644 --- a/lib/routes/infoq/utils.js +++ b/lib/routes/infoq/utils.js @@ -14,8 +14,7 @@ const ProcessFeed = async (list, cache) => { headers: { Referer: link, }, - json: true, - data: { + json: { uuid: uuid, }, }); diff --git a/lib/routes/jingdong/zhongchou.js b/lib/routes/jingdong/zhongchou.js index ecc6bc947..bd211bb43 100644 --- a/lib/routes/jingdong/zhongchou.js +++ b/lib/routes/jingdong/zhongchou.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const url = require('url'); +const queryString = require('query-string'); const contentUrl = 'https://z.jd.com/bigger/search.html'; const host = 'https://z.jd.com/'; @@ -48,7 +49,7 @@ module.exports = async (ctx) => { headers: { 'Content-type': 'application/x-www-form-urlencoded', }, - params: params, + searchParams: queryString.stringify(params), }); const $ = cheerio.load(response.data); diff --git a/lib/routes/juejin/pins.js b/lib/routes/juejin/pins.js index 6e4a55e64..8d96de0fd 100644 --- a/lib/routes/juejin/pins.js +++ b/lib/routes/juejin/pins.js @@ -4,8 +4,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: 'https://web-api.juejin.im/graphql', - json: true, - data: { operationName: '', query: '', variables: { size: 20, after: '', afterPosition: '' }, extensions: { query: { id: '964dab26a3f9997283d173b865509890' } } }, + json: { operationName: '', query: '', variables: { size: 20, after: '', afterPosition: '' }, extensions: { query: { id: '964dab26a3f9997283d173b865509890' } } }, headers: { 'X-Agent': 'Juejin/Web', }, diff --git a/lib/routes/konachan/post_popular_recent.js b/lib/routes/konachan/post_popular_recent.js index 9b753536a..84e71d1d0 100644 --- a/lib/routes/konachan/post_popular_recent.js +++ b/lib/routes/konachan/post_popular_recent.js @@ -1,4 +1,5 @@ const got = require('@/utils/got'); +const queryString = require('query-string'); module.exports = async (ctx) => { const { period = '1d' } = ctx.params; @@ -10,9 +11,9 @@ module.exports = async (ctx) => { method: 'get', baseUrl, url: '/post/popular_recent.json', - params: { + searchParams: queryString.stringify({ period, - }, + }), }); const posts = response.data; diff --git a/lib/routes/laosiji/hotshow.js b/lib/routes/laosiji/hotshow.js index 9f8309930..c41d8cf43 100644 --- a/lib/routes/laosiji/hotshow.js +++ b/lib/routes/laosiji/hotshow.js @@ -10,8 +10,7 @@ module.exports = async (ctx) => { headers: { Referer: link, }, - form: true, - data: { + form: { hotShowId: id, sort: 1, pageNo: 1, diff --git a/lib/routes/linkedkeeper/index.js b/lib/routes/linkedkeeper/index.js index 7ed91710c..3fcd8651b 100644 --- a/lib/routes/linkedkeeper/index.js +++ b/lib/routes/linkedkeeper/index.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const queryString = require('query-string'); module.exports = async (ctx) => { const type = ctx.params.type; @@ -8,10 +9,10 @@ module.exports = async (ctx) => { const res = await got({ method: 'get', url: `http://www.linkedkeeper.com/list/${type}.action`, - params: { + searchParams: queryString.stringify({ sid: id, tid: id, - }, + }), }); const $ = cheerio.load(res.data); const list = $('tbody').find('td'); diff --git a/lib/routes/liwushuo/index.js b/lib/routes/liwushuo/index.js index 1f4eae975..739c78953 100644 --- a/lib/routes/liwushuo/index.js +++ b/lib/routes/liwushuo/index.js @@ -4,7 +4,7 @@ module.exports = async (ctx) => { const baseUrl = 'https://www.liwushuo.com'; const link = `${baseUrl}/api/channels/1/items`; const res = await got(link, { - query: { + searchParams: { limit: 21, }, }); diff --git a/lib/routes/matters/latest.js b/lib/routes/matters/latest.js index 54af71409..33c9c2909 100644 --- a/lib/routes/matters/latest.js +++ b/lib/routes/matters/latest.js @@ -5,8 +5,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: 'https://server.matters.news/graphql', - json: true, - data: { + json: { operationName: 'NewestFeed', variables: { hasArticleDigestActionAuthor: false, diff --git a/lib/routes/mcbbs/forum.js b/lib/routes/mcbbs/forum.js index 26739e5a8..3a8d11ce9 100644 --- a/lib/routes/mcbbs/forum.js +++ b/lib/routes/mcbbs/forum.js @@ -1,20 +1,21 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const utils = require('./utils'); +const queryString = require('query-string'); module.exports = async (ctx) => { const type = ctx.params.type; const response = await got(utils.forumUrl, { method: 'get', - params: { + searchParams: queryString.stringify({ mod: 'forumdisplay', fid: type, // 最新帖子 filter: 'lastpost', orderby: 'lastpost', - }, - baseUrl: utils.host, + }), + prefixUrl: utils.host, }); const data = response.data; const $ = cheerio.load(data); diff --git a/lib/routes/mcbbs/post.js b/lib/routes/mcbbs/post.js index e4411a977..451ddc7a4 100644 --- a/lib/routes/mcbbs/post.js +++ b/lib/routes/mcbbs/post.js @@ -1,20 +1,21 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const utils = require('./utils'); +const queryString = require('query-string'); module.exports = async (ctx) => { const tid = ctx.params.tid; const authorid = ctx.params.authorid; const response = await got(utils.forumUrl, { method: 'get', - params: { + searchParams: queryString.stringify({ mod: 'viewthread', tid: tid, authorid: authorid, // 倒序查看帖子 ordertype: 1, - }, - baseUrl: utils.host, + }), + prefixUrl: utils.host, }); const data = response.data; const $ = cheerio.load(data); diff --git a/lib/routes/mcbbs/utils.js b/lib/routes/mcbbs/utils.js index ff1cb4e7e..5b1e89e41 100644 --- a/lib/routes/mcbbs/utils.js +++ b/lib/routes/mcbbs/utils.js @@ -1,6 +1,6 @@ const utils = { host: 'https://www.mcbbs.net', - forumUrl: '/forum.php', + forumUrl: 'forum.php', }; module.exports = utils; diff --git a/lib/routes/mi/miui/index.js b/lib/routes/mi/miui/index.js index 5d84fa087..c2a0e7cd9 100644 --- a/lib/routes/mi/miui/index.js +++ b/lib/routes/mi/miui/index.js @@ -1,4 +1,5 @@ const got = require('@/utils/got'); +const queryString = require('query-string'); const cacheLength = 5; @@ -11,15 +12,14 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', - baseUrl: 'http://update.miui.com', - url: '/updates/miota-fullrom.php', - params: { + url: 'http://update.miui.com/updates/miota-fullrom.php', + searchParams: queryString.stringify({ d: device, b: releaseType, r: regionName, l: 'zh_CN', n: '', - }, + }), }); const responseData = response.data; diff --git a/lib/routes/mihoyo/bh3.js b/lib/routes/mihoyo/bh3.js index 36083c03e..373fac390 100644 --- a/lib/routes/mihoyo/bh3.js +++ b/lib/routes/mihoyo/bh3.js @@ -1,4 +1,5 @@ const got = require('@/utils/got'); +const queryString = require('query-string'); module.exports = async (ctx) => { const url = 'https://www.bh3.com/index.php/news/_more'; @@ -21,10 +22,10 @@ module.exports = async (ctx) => { Referer: url, 'x-requested-with': 'XMLHttpRequest', }, - params: { + searchParams: queryString.stringify({ begin: new Date(), type: type, - }, + }), }); const data = response.data.data.data; diff --git a/lib/routes/ncm/djradio.js b/lib/routes/ncm/djradio.js index a9d1e728a..569146a56 100644 --- a/lib/routes/ncm/djradio.js +++ b/lib/routes/ncm/djradio.js @@ -9,8 +9,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://music.163.com/', }, - form: true, - data: { + form: { radioId: id, limit: 1000, offset: 0, diff --git a/lib/routes/ncm/playlist.js b/lib/routes/ncm/playlist.js index 6b4b886c2..5af6d8abe 100644 --- a/lib/routes/ncm/playlist.js +++ b/lib/routes/ncm/playlist.js @@ -9,8 +9,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://music.163.com/', }, - form: true, - data: { + form: { id: id, }, }); diff --git a/lib/routes/ncm/userplaylist.js b/lib/routes/ncm/userplaylist.js index 959b5a1d0..2b146f779 100644 --- a/lib/routes/ncm/userplaylist.js +++ b/lib/routes/ncm/userplaylist.js @@ -9,8 +9,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://music.163.com/', }, - form: true, - data: { + form: { uid: uid, limit: 1000, offset: 0, diff --git a/lib/routes/nga/forum.js b/lib/routes/nga/forum.js index 12284352d..6282964b0 100644 --- a/lib/routes/nga/forum.js +++ b/lib/routes/nga/forum.js @@ -15,8 +15,7 @@ module.exports = async (ctx) => { headers: { 'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)', }, - form: true, - data: { + form: { fid, recommend: recommend ? 1 : 0, }, @@ -43,8 +42,7 @@ module.exports = async (ctx) => { headers: { 'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)', }, - form: true, - data: { + form: { tid, }, }); diff --git a/lib/routes/nintendo/eshop_us.js b/lib/routes/nintendo/eshop_us.js index 9ac051356..12581d875 100644 --- a/lib/routes/nintendo/eshop_us.js +++ b/lib/routes/nintendo/eshop_us.js @@ -4,8 +4,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: `https://u3b6gr4ua3-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.22.1%3BJS%20Helper%202.20.1&x-algolia-application-id=U3B6GR4UA3&x-algolia-api-key=9a20c93440cf63cf1a7008d75f7438bf`, - json: true, - data: { + json: { requests: [ { indexName: 'noa_aem_game_en_us_release_des', diff --git a/lib/routes/owspace/read.js b/lib/routes/owspace/read.js index 2aad03be0..c83087588 100644 --- a/lib/routes/owspace/read.js +++ b/lib/routes/owspace/read.js @@ -120,7 +120,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url: 'http://static.owspace.com/', - query: qs.stringify(queryData), + searchParams: qs.stringify(queryData), headers: { 'User-Agent': 'com.onewaystreet.weread/14', }, diff --git a/lib/routes/patchwork.kernel.org/comments.js b/lib/routes/patchwork.kernel.org/comments.js index 5112837c2..27259de18 100644 --- a/lib/routes/patchwork.kernel.org/comments.js +++ b/lib/routes/patchwork.kernel.org/comments.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const cache = require('./cache'); const he = require('he'); +const queryString = require('query-string'); module.exports = async (ctx) => { const id = ctx.params.id; @@ -13,9 +14,9 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url, - params: { + searchParams: queryString.stringify({ order: '-date', - }, + }), }); const data = response.data; diff --git a/lib/routes/pingwest/status.js b/lib/routes/pingwest/status.js index db4a97834..3a3944064 100644 --- a/lib/routes/pingwest/status.js +++ b/lib/routes/pingwest/status.js @@ -5,7 +5,7 @@ module.exports = async (ctx) => { const baseUrl = 'https://www.pingwest.com'; const url = `${baseUrl}/api/state/list`; const response = await got(url, { - query: { + searchParams: { page: 1, }, headers: { diff --git a/lib/routes/pingwest/tag.js b/lib/routes/pingwest/tag.js index c29747df6..fd640605d 100644 --- a/lib/routes/pingwest/tag.js +++ b/lib/routes/pingwest/tag.js @@ -18,7 +18,7 @@ module.exports = async (ctx) => { }); const url = `${baseUrl}/api/tag_article_list`; const response = await got(url, { - query: { + searchParams: { page: 1, id: tagId, type, diff --git a/lib/routes/pingwest/user.js b/lib/routes/pingwest/user.js index 81204ddd3..cf40cabfe 100644 --- a/lib/routes/pingwest/user.js +++ b/lib/routes/pingwest/user.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { }); const url = `${baseUrl}/api/user_data`; const response = await got(url, { - query: { + searchParams: { page: 1, user_id: realUid, tab: type, diff --git a/lib/routes/pintu360/index.js b/lib/routes/pintu360/index.js index 68229f216..5e76b1301 100644 --- a/lib/routes/pintu360/index.js +++ b/lib/routes/pintu360/index.js @@ -10,8 +10,7 @@ module.exports = async (ctx) => { headers: { Referer: 'https://www.pintu360.com/', }, - form: true, - data: { + form: { fnName: 'getArticleList', type: type === '0' ? 'recommend' : 'classId', id: type, diff --git a/lib/routes/pixiv/api/getBookmarks.js b/lib/routes/pixiv/api/getBookmarks.js index 658724f4a..a446f8e3b 100644 --- a/lib/routes/pixiv/api/getBookmarks.js +++ b/lib/routes/pixiv/api/getBookmarks.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * 获取用户的收藏 @@ -16,9 +17,9 @@ module.exports = async function getBookmarks(user_id, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ user_id: user_id, restrict: 'public', - }, + }), }); }; diff --git a/lib/routes/pixiv/api/getIllustFollows.js b/lib/routes/pixiv/api/getIllustFollows.js index f857fe3fe..d73908ca5 100644 --- a/lib/routes/pixiv/api/getIllustFollows.js +++ b/lib/routes/pixiv/api/getIllustFollows.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * 获取用户关注的画师们的最新插画 @@ -14,8 +15,8 @@ module.exports = async function getUserIllustFollows(token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ restrict: 'public', - }, + }), }); }; diff --git a/lib/routes/pixiv/api/getIllusts.js b/lib/routes/pixiv/api/getIllusts.js index c2d563036..cd764d9c7 100644 --- a/lib/routes/pixiv/api/getIllusts.js +++ b/lib/routes/pixiv/api/getIllusts.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * 获取用户插画作品 @@ -15,10 +16,10 @@ module.exports = async function getIllusts(user_id, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ user_id: user_id, filter: 'for_ios', type: 'illust', - }, + }), }); }; diff --git a/lib/routes/pixiv/api/getRanking.js b/lib/routes/pixiv/api/getRanking.js index 33c7994cf..da1c48dae 100644 --- a/lib/routes/pixiv/api/getRanking.js +++ b/lib/routes/pixiv/api/getRanking.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; const assert = require('assert'); +const queryString = require('query-string'); const allowMode = ['day', 'week', 'month', 'day_male', 'day_female', 'week_original', 'week_rookie', 'day_r18', 'day_male_r18', 'day_female_r18', 'week_r18', 'week_r18g']; @@ -20,12 +21,12 @@ module.exports = async function getRanking(mode, date, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ mode: mode, filter: 'for_ios', ...(date && { date: `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`, }), - }, + }), }); }; diff --git a/lib/routes/pixiv/api/getUserDetail.js b/lib/routes/pixiv/api/getUserDetail.js index c1717ed4d..7c750adbb 100644 --- a/lib/routes/pixiv/api/getUserDetail.js +++ b/lib/routes/pixiv/api/getUserDetail.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * pixiv 用户 @@ -21,8 +22,8 @@ module.exports = async function getUserDetail(user_id, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ user_id: user_id, - }, + }), }); }; diff --git a/lib/routes/pixiv/api/searchIllust.js b/lib/routes/pixiv/api/searchIllust.js index 503b28607..affb418a8 100644 --- a/lib/routes/pixiv/api/searchIllust.js +++ b/lib/routes/pixiv/api/searchIllust.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * 按时间排序搜索内容 @@ -15,11 +16,11 @@ module.exports = async function searchIllust(keyword, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ word: keyword, search_target: 'partial_match_for_tags', sort: 'date_desc', filter: 'for_ios', - }, + }), }); }; diff --git a/lib/routes/pixiv/api/searchPopularIllust.js b/lib/routes/pixiv/api/searchPopularIllust.js index e6581b28b..ded3f1bbe 100644 --- a/lib/routes/pixiv/api/searchPopularIllust.js +++ b/lib/routes/pixiv/api/searchPopularIllust.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const maskHeader = require('../constants').maskHeader; +const queryString = require('query-string'); /** * 按热门排序搜索内容 @@ -15,10 +16,10 @@ module.exports = async function searchPopularIllust(keyword, token) { ...maskHeader, Authorization: 'Bearer ' + token, }, - params: { + searchParams: queryString.stringify({ word: keyword, search_target: 'partial_match_for_tags', filter: 'for_ios', - }, + }), }); }; diff --git a/lib/routes/pixiv/token.js b/lib/routes/pixiv/token.js index b319808a3..23ceb9a6b 100644 --- a/lib/routes/pixiv/token.js +++ b/lib/routes/pixiv/token.js @@ -1,7 +1,6 @@ const config = require('@/config').value; const logger = require('@/utils/logger'); const wait = require('@/utils/wait'); -const FormData = require('form-data'); const got = require('@/utils/got'); const maskHeader = require('./constants').maskHeader; const md5 = require('@/utils/md5'); @@ -19,28 +18,19 @@ const authorizationInfo = { }; async function getToken() { - const data = new FormData(); - const jsonData = { - ...authorizationInfo, - get_secure_url: 1, - grant_type: 'password', - }; - for (const key in jsonData) { - if (jsonData.hasOwnProperty(key)) { - const element = jsonData[key]; - data.append(key, element); - } - } const localTime = new Date().toISOString().replace(/\..+/, '') + '+00:00'; const response = await got({ method: 'post', url: 'https://oauth.secure.pixiv.net/auth/token', - data: data, + form: { + ...authorizationInfo, + get_secure_url: 1, + grant_type: 'password', + }, headers: { 'X-Client-Time': localTime, 'X-Client-Hash': md5(localTime + authorizationInfo.hash_secret), ...maskHeader, - ...data.getHeaders(), }, }).catch(function() { logger.error('Pixiv login fail.'); @@ -49,26 +39,17 @@ async function getToken() { } async function refreshToken(refresh_token) { - const data = new FormData(); - const jsonData = { - ...authorizationInfo, - get_secure_url: 1, - grant_type: 'refresh_token', - refresh_token: refresh_token, - }; - for (const key in jsonData) { - if (jsonData.hasOwnProperty(key)) { - const element = jsonData[key]; - data.append(key, element); - } - } const response = await got({ method: 'post', url: 'https://oauth.secure.pixiv.net/auth/token', - data: data, + form: { + ...authorizationInfo, + get_secure_url: 1, + grant_type: 'refresh_token', + refresh_token: refresh_token, + }, headers: { ...maskHeader, - ...data.getHeaders(), }, }); return response.data.response; diff --git a/lib/routes/pmcaff/list.js b/lib/routes/pmcaff/list.js index 4af69f812..31fa3084c 100644 --- a/lib/routes/pmcaff/list.js +++ b/lib/routes/pmcaff/list.js @@ -14,8 +14,7 @@ module.exports = async (ctx) => { headers: { Referer: url, }, - json: true, - data: { + json: { page: 1, feed_sum: 15, type: typeid, diff --git a/lib/routes/polimi/news.js b/lib/routes/polimi/news.js index 84717343e..4f1201941 100644 --- a/lib/routes/polimi/news.js +++ b/lib/routes/polimi/news.js @@ -1,4 +1,5 @@ const buildData = require('@/utils/common-config'); +const queryString = require('query-string'); module.exports = async (ctx) => { let link = `https://www.polimi.it/tutte-le-news/`; @@ -9,9 +10,9 @@ module.exports = async (ctx) => { link, url: link, title: `Polimi News`, - params: { + searchParams: queryString.stringify({ homeLink: 'https://www.polimi.it', - }, + }), item: { item: '.container .no', title: `$('h3').text()`, diff --git a/lib/routes/queshu/book.js b/lib/routes/queshu/book.js index c016eac81..a2769b4f3 100644 --- a/lib/routes/queshu/book.js +++ b/lib/routes/queshu/book.js @@ -1,4 +1,5 @@ const buildData = require('@/utils/common-config'); +const queryString = require('query-string'); module.exports = async (ctx) => { const bookid = ctx.params.bookid; @@ -9,10 +10,10 @@ module.exports = async (ctx) => { url: link, title: `%title%`, allowEmpty: true, - params: { + searchParams: queryString.stringify({ title: `$('#book_left > #h1').text().trim() + ' - 单品活动信息 - 缺书网'`, host, - }, + }), item: { item: '.stacked.right_state > a', title: `$('.right_item .bodycol_258').text()`, diff --git a/lib/routes/queshu/sale.js b/lib/routes/queshu/sale.js index 1a2a0ea58..276d58fdb 100644 --- a/lib/routes/queshu/sale.js +++ b/lib/routes/queshu/sale.js @@ -1,4 +1,5 @@ const buildData = require('@/utils/common-config'); +const queryString = require('query-string'); module.exports = async (ctx) => { const link = `http://www.queshu.com/sale/`; @@ -7,10 +8,10 @@ module.exports = async (ctx) => { link, url: link, title: `%title%`, - params: { + searchParams: queryString.stringify({ title: '图书促销 - 缺书网', host, - }, + }), item: { item: '#tb_sale tr', title: `$('.news_sale_detail .sale_btn').text() + ':' + $('.news_sale_title a').text()`, diff --git a/lib/routes/saraba1st/thread.js b/lib/routes/saraba1st/thread.js index c23f9267e..7c06c31cb 100644 --- a/lib/routes/saraba1st/thread.js +++ b/lib/routes/saraba1st/thread.js @@ -2,16 +2,17 @@ const url = require('url'); const got = require('@/utils/got'); const cheerio = require('cheerio'); const date = require('@/utils/date'); +const queryString = require('query-string'); module.exports = async (ctx) => { const tid = ctx.params.tid; const res = await got.get('https://bbs.saraba1st.com/2b/forum.php', { - params: { + searchParams: queryString.stringify({ mod: 'viewthread', tid: tid, ordertype: 1, - }, + }), }); const $ = cheerio.load(res.data); diff --git a/lib/routes/sf/sffq-announce.js b/lib/routes/sf/sffq-announce.js index fcf1fb9c9..af9dd8ec0 100644 --- a/lib/routes/sf/sffq-announce.js +++ b/lib/routes/sf/sffq-announce.js @@ -5,8 +5,7 @@ module.exports = async (ctx) => { await got({ method: 'post', url: 'https://qiao.sf-express.com/menu/getListNews.pub', - json: true, - data: {}, + json: {}, }) ).data; diff --git a/lib/routes/steam/news.js b/lib/routes/steam/news.js index 854433b65..c139bb94b 100644 --- a/lib/routes/steam/news.js +++ b/lib/routes/steam/news.js @@ -1,10 +1,11 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const queryString = require('query-string'); module.exports = async (ctx) => { const { appids } = ctx.params; const { data: html } = await got.get(`https://store.steampowered.com/news/`, { - params: { appids }, + searchParams: queryString.stringify({ appids }), }); const $ = cheerio.load(html); diff --git a/lib/routes/steam/search.js b/lib/routes/steam/search.js index 40dbb4738..7e76ca4e3 100644 --- a/lib/routes/steam/search.js +++ b/lib/routes/steam/search.js @@ -1,12 +1,13 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const qs = require('querystring'); +const queryString = require('query-string'); module.exports = async (ctx) => { const { params } = ctx.params; const query = qs.parse(params); const { data: html } = await got.get(`https://store.steampowered.com/search/results`, { - params: query, + searchParams: queryString.stringify(query), }); const $ = cheerio.load(html); diff --git a/lib/routes/topys/article.js b/lib/routes/topys/article.js index b68f41b41..84e4dcb72 100644 --- a/lib/routes/topys/article.js +++ b/lib/routes/topys/article.js @@ -16,8 +16,7 @@ module.exports = async (ctx) => { const response = await got({ method: 'post', url: 'https://www.topys.cn/ajax/article/get_article_list', - form: true, - data: { + form: { needloginpage: 2, islogin: 0, module: 'article', diff --git a/lib/routes/universities/csu/job.js b/lib/routes/universities/csu/job.js index 52e761a6c..510768a66 100644 --- a/lib/routes/universities/csu/job.js +++ b/lib/routes/universities/csu/job.js @@ -8,10 +8,7 @@ module.exports = async (ctx) => { const type = ctx.params.type || 1; const link = 'http://jobsky.csu.edu.cn/Home/PartialArticleList'; const response = await got.post(link, { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: 'pageindex=1&pagesize=10&typeid=' + type + '&followingdates=-1', + form: 'pageindex=1&pagesize=10&typeid=' + type + '&followingdates=-1', }); const $ = cheerio.load('