fix: post type

This commit is contained in:
DIYgod
2019-06-04 18:28:06 +08:00
parent 218c06f96c
commit ea508b8bc2
28 changed files with 66 additions and 75 deletions

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
const iconv = require('iconv-lite'); const iconv = require('iconv-lite');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
@@ -13,11 +12,11 @@ module.exports = {
url: 'https://space.bilibili.com/ajax/member/GetInfo', url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: { headers: {
Referer: `https://space.bilibili.com/${uid}/`, Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
}, },
data: qs.stringify({ form: true,
data: {
mid: uid, mid: uid,
}), },
}); });
name = nameResponse.data.data.name; name = nameResponse.data.data.name;
ctx.cache.set(key, name); ctx.cache.set(key, name);

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const region = ctx.params.region || 1; const region = ctx.params.region || 1;
@@ -8,14 +7,12 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', method: 'post',
url: api, url: api,
headers: { form: true,
'Content-Type': 'application/x-www-form-urlencoded', data: {
},
data: qs.stringify({
region: region, region: region,
dateType: 2, dateType: 2,
magnitude: 0, magnitude: 0,
}), },
}); });
const data = response.data; const data = response.data;

View File

@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/intro', url: 'https://time.geekbang.org/serv/v1/column/intro',
headers: { headers: {
Referer: 'https://time.geekbang.org/', Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
cid: column_id, cid: column_id,
}, },
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/articles/latest', url: 'https://time.geekbang.org/serv/v1/column/articles/latest',
headers: { headers: {
Referer: 'https://time.geekbang.org/', Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
cid: column_id, cid: column_id,
}, },

View File

@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/intro', url: 'https://time.geekbang.org/serv/v1/column/intro',
headers: { headers: {
Referer: 'https://time.geekbang.org/', Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
cid: column_id, cid: column_id,
}, },
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/audios', url: 'https://time.geekbang.org/serv/v1/column/audios',
headers: { headers: {
Referer: 'https://time.geekbang.org/', Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
cid: column_id, cid: column_id,
}, },

View File

@@ -13,6 +13,7 @@ module.exports = async (ctx) => {
headers: { headers: {
Authorization: `bearer ${config.github.access_token}`, Authorization: `bearer ${config.github.access_token}`,
}, },
json: true,
data: { data: {
query: ` query: `
{ {

View File

@@ -14,6 +14,7 @@ module.exports = async (ctx) => {
headers: { headers: {
Authorization: `bearer ${config.github.access_token}`, Authorization: `bearer ${config.github.access_token}`,
}, },
json: true,
data: { data: {
query: ` query: `
{ {

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const link = 'https://www.icourse163.org/category/all'; const link = 'https://www.icourse163.org/category/all';
@@ -13,16 +12,16 @@ module.exports = async (ctx) => {
method: 'post', method: 'post',
url: `https://www.icourse163.org/web/j/courseBean.getCoursePanelListByFrontCategory.rpc?csrfKey=${csrfKey}`, url: `https://www.icourse163.org/web/j/courseBean.getCoursePanelListByFrontCategory.rpc?csrfKey=${csrfKey}`,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Cookie: `NTESSTUDYSI=${csrfKey};`, Cookie: `NTESSTUDYSI=${csrfKey};`,
}, },
data: qs.stringify({ form: true,
data: {
categoryId: -1, categoryId: -1,
type: 30, type: 30,
orderBy: 10, orderBy: 10,
pageIndex: 1, pageIndex: 1,
pageSize: 20, pageSize: 20,
}), },
}); });
const items = response.data.result.result.map((item) => { const items = response.data.result.result.map((item) => {

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const category = ctx.params.category; const category = ctx.params.category;
@@ -12,11 +11,12 @@ module.exports = async (ctx) => {
headers: { headers: {
Referer: url, Referer: url,
}, },
form: true,
url: api_url, url: api_url,
data: qs.stringify({ data: {
pageNo: 1, pageNo: 1,
catid: `${category}`, catid: `${category}`,
}), },
}); });
const data = response.data; const data = response.data;

View File

@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: apiUrl, url: apiUrl,
headers: { headers: {
Referer: pageUrl, Referer: pageUrl,
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
size: 5, size: 5,
}, },

View File

@@ -12,8 +12,8 @@ module.exports = async (ctx) => {
url: infoUrl, url: infoUrl,
headers: { headers: {
Referer: pageUrl, Referer: pageUrl,
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
id: paramId, id: paramId,
}, },
@@ -26,8 +26,8 @@ module.exports = async (ctx) => {
url: apiUrl, url: apiUrl,
headers: { headers: {
Referer: pageUrl, Referer: pageUrl,
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
size: 5, size: 5,
type: type, type: type,

View File

@@ -13,8 +13,8 @@ const ProcessFeed = async (list, cache) => {
url: detailUrl, url: detailUrl,
headers: { headers: {
Referer: link, Referer: link,
'Content-Type': 'application/json',
}, },
json: true,
data: { data: {
uuid: uuid, uuid: uuid,
}, },

View File

@@ -13,6 +13,7 @@ module.exports = async (ctx) => {
Referer: `https://m.okjike.com/topics/${id}`, Referer: `https://m.okjike.com/topics/${id}`,
'App-Version': '4.12.0', 'App-Version': '4.12.0',
}, },
json: true,
data: { data: {
loadMoreKey: null, loadMoreKey: null,
topic: id, topic: id,

View File

@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
Referer: `https://m.okjike.com/topics/${id}`, Referer: `https://m.okjike.com/topics/${id}`,
'App-Version': '4.12.0', 'App-Version': '4.12.0',
}, },
json: true,
data: { data: {
loadMoreKey: null, loadMoreKey: null,
topicId: id, topicId: id,

View File

@@ -12,6 +12,7 @@ module.exports = async (ctx) => {
Referer: `https://m.okjike.com/topics/${id}`, Referer: `https://m.okjike.com/topics/${id}`,
'App-Version': '4.12.0', 'App-Version': '4.12.0',
}, },
json: true,
data: { data: {
loadMoreKey: null, loadMoreKey: null,
topic: id, topic: id,

View File

@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
'App-Version': '4.12.0', 'App-Version': '4.12.0',
platform: 'web', platform: 'web',
}, },
json: true,
data: { data: {
limit: 20, limit: 20,
loadMoreKey: null, loadMoreKey: null,

View File

@@ -4,6 +4,7 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', method: 'post',
url: 'https://web-api.juejin.im/graphql', url: 'https://web-api.juejin.im/graphql',
json: true,
data: { operationName: '', query: '', variables: { size: 20, after: '', afterPosition: '' }, extensions: { query: { id: '964dab26a3f9997283d173b865509890' } } }, data: { operationName: '', query: '', variables: { size: 20, after: '', afterPosition: '' }, extensions: { query: { id: '964dab26a3f9997283d173b865509890' } } },
headers: { headers: {
'X-Agent': 'Juejin/Web', 'X-Agent': 'Juejin/Web',

View File

@@ -1,6 +1,5 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const parseDate = require('@/utils/date'); const parseDate = require('@/utils/date');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const { id } = ctx.params; const { id } = ctx.params;
@@ -10,13 +9,13 @@ module.exports = async (ctx) => {
url: 'http://www.laosiji.com/api/hotShow/program', url: 'http://www.laosiji.com/api/hotShow/program',
headers: { headers: {
Referer: link, Referer: link,
'Content-Type': 'application/x-www-form-urlencoded',
}, },
data: qs.stringify({ form: true,
data: {
hotShowId: id, hotShowId: id,
sort: 1, sort: 1,
pageNo: 1, pageNo: 1,
}), },
}); });
const data = response.data.body.hotshow; const data = response.data.body.hotshow;

View File

@@ -5,6 +5,7 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', method: 'post',
url: 'https://server.matters.news/', url: 'https://server.matters.news/',
json: true,
data: { data: {
operationName: 'NewestFeed', operationName: 'NewestFeed',
variables: { variables: {

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const id = ctx.params.id; const id = ctx.params.id;
@@ -9,13 +8,13 @@ module.exports = async (ctx) => {
url: 'http://music.163.com/api/dj/program/byradio', url: 'http://music.163.com/api/dj/program/byradio',
headers: { headers: {
Referer: 'https://music.163.com/', Referer: 'https://music.163.com/',
'Content-Type': 'application/x-www-form-urlencoded',
}, },
data: qs.stringify({ form: true,
data: {
radioId: id, radioId: id,
limit: 1000, limit: 1000,
offset: 0, offset: 0,
}), },
}); });
const programs = response.data.programs || []; const programs = response.data.programs || [];

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const id = ctx.params.id; const id = ctx.params.id;
@@ -9,11 +8,11 @@ module.exports = async (ctx) => {
url: 'https://music.163.com/api/v3/playlist/detail', url: 'https://music.163.com/api/v3/playlist/detail',
headers: { headers: {
Referer: 'https://music.163.com/', Referer: 'https://music.163.com/',
'Content-Type': 'application/x-www-form-urlencoded',
}, },
data: qs.stringify({ form: true,
data: {
id: id, id: id,
}), },
}); });
const data = response.data.playlist; const data = response.data.playlist;

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const uid = ctx.params.uid; const uid = ctx.params.uid;
@@ -9,13 +8,13 @@ module.exports = async (ctx) => {
url: 'http://music.163.com/api/user/playlist', url: 'http://music.163.com/api/user/playlist',
headers: { headers: {
Referer: 'https://music.163.com/', Referer: 'https://music.163.com/',
'Content-Type': 'application/x-www-form-urlencoded',
}, },
data: qs.stringify({ form: true,
data: {
uid: uid, uid: uid,
limit: 1000, limit: 1000,
offset: 0, offset: 0,
}), },
}); });
const playlist = response.data.playlist || []; const playlist = response.data.playlist || [];

View File

@@ -1,21 +1,17 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const { fid } = ctx.params; const { fid } = ctx.params;
const gotInstance = got.extend({ const homePage = await got({
baseURL: 'https://ngabbs.com/app_api.php', method: 'post',
url: 'https://ngabbs.com/app_api.php?__lib=subject&__act=list',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)', 'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)',
}, },
}); form: true,
const homePage = await gotInstance.request({ data: {
method: 'post',
url: '?__lib=subject&__act=list',
data: qs.stringify({
fid, fid,
}), },
}); });
const list = homePage.data.result.data.filter(({ tid }) => tid); const list = homePage.data.result.data.filter(({ tid }) => tid);
@@ -31,12 +27,16 @@ module.exports = async (ctx) => {
}; };
const description = await ctx.cache.tryGet(`nga-forum: ${link}`, async () => { const description = await ctx.cache.tryGet(`nga-forum: ${link}`, async () => {
const response = await gotInstance.request({ const response = await got({
method: 'post', method: 'post',
url: '?__lib=post&__act=list', url: 'https://ngabbs.com/app_api.php?__lib=subject&__act=list?__lib=post&__act=list',
data: qs.stringify({ headers: {
'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)',
},
form: true,
data: {
tid, tid,
}), },
}); });
return response.data.result[0].content; return response.data.result[0].content;

View File

@@ -4,6 +4,7 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', 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`, 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: { data: {
requests: [ requests: [
{ {

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const { orgNo, provinceNo, scope = '', typeCode = '', lineName = '' } = ctx.params; const { orgNo, provinceNo, scope = '', typeCode = '', lineName = '' } = ctx.params;
@@ -14,10 +13,8 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', method: 'post',
url: 'http://www.95598.cn/95598/outageNotice/queryOutageNoticeList', url: 'http://www.95598.cn/95598/outageNotice/queryOutageNoticeList',
headers: { form: true,
'Content-Type': 'application/x-www-form-urlencoded', data: {
},
data: qs.stringify({
orgNo, orgNo,
outageStartTime, outageStartTime,
outageEndTime, outageEndTime,
@@ -26,7 +23,7 @@ module.exports = async (ctx) => {
typeCode, typeCode,
lineName, lineName,
anHui, anHui,
}), },
}); });
const items = (response.data.seleList || []).map((item) => { const items = (response.data.seleList || []).map((item) => {

View File

@@ -1,7 +1,6 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const url = require('url'); const url = require('url');
const qs = require('querystring');
const baseUrl = 'http://jwc.scuteo.com/'; const baseUrl = 'http://jwc.scuteo.com/';
@@ -21,14 +20,12 @@ module.exports = async (ctx) => {
const listResponse = await got({ const listResponse = await got({
method: 'post', method: 'post',
url: baseUrl + 'jiaowuchu/cms/category/index.do', url: baseUrl + 'jiaowuchu/cms/category/index.do',
headers: { form: true,
'Content-Type': 'application/x-www-form-urlencoded', data: {
},
data: qs.stringify({
id: categoryData.id, id: categoryData.id,
offset: 0, offset: 0,
pagesize: 20, pagesize: 20,
}), },
}); });
const itemList = listResponse.data.results.splice(0, 10); const itemList = listResponse.data.results.splice(0, 10);

View File

@@ -5,6 +5,7 @@ module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'post', method: 'post',
url: 'https://uapi.vip.qq.com/Api/api.brand.productssrf', url: 'https://uapi.vip.qq.com/Api/api.brand.productssrf',
json: true,
data: { data: {
page: 1, page: 1,
per_page: 20, per_page: 20,

View File

@@ -1,5 +1,4 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const qs = require('querystring');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const city = ctx.params.city || 'sh'; const city = ctx.params.city || 'sh';
@@ -14,14 +13,15 @@ module.exports = async (ctx) => {
headers: { headers: {
Referer: `http://${domain}/${city.toUpperCase()}/search.html`, Referer: `http://${domain}/${city.toUpperCase()}/search.html`,
}, },
data: qs.stringify({ form: true,
data: {
recent_money: 0, recent_money: 0,
sort: 0, sort: 0,
is_whole: iswhole, is_whole: iswhole,
room: room, room: room,
key_word: keyword, key_word: keyword,
step: 0, step: 0,
}), },
}); });
let data = response.data.data; // 当查询的结果不存在时,该 data 是个对象 { info: '数据加载完毕' } let data = response.data.data; // 当查询的结果不存在时,该 data 是个对象 { info: '数据加载完毕' }
// 判断数据的类型,如果有数据就是数组类型的,没有数据的话,就赋值为空数组 // 判断数据的类型,如果有数据就是数组类型的,没有数据的话,就赋值为空数组

View File

@@ -79,11 +79,7 @@ const custom = got.extend({
(options) => { (options) => {
// compatible with axios api // compatible with axios api
if (options.data) { if (options.data) {
if (typeof options.data === 'object') { options.body = options.body || options.data;
options.json = options.json || options.data;
} else {
options.body = options.body || options.data;
}
} }
if (options.responseType === 'buffer') { if (options.responseType === 'buffer') {
options.encoding = null; options.encoding = null;