diff --git a/docs/README.md b/docs/README.md
index 75d024cc1..53a2acf6c 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -823,27 +823,21 @@ GitHub 官方也提供了一些 RSS:
### 妹子图
-::: warning 注意
+
-该网站在国外无法访问, 由于 RSSHub 演示部署于国外, 故以下演示无效.
+
-:::
-
-
-
-
-
-| 热门 | 推荐 | 性感妹子 | 日本妹子 | 台湾妹子 | 清纯妹子 |
-| ---- | ---- | -------- | -------- | -------- | -------- |
-| hot | best | xinggan | japan | taiwan | mm |
+| 性感妹子 | 日本妹子 | 台湾妹子 | 清纯妹子 |
+| -------- | -------- | -------- | -------- |
+| xinggan | japan | taiwan | mm |
-
+
-
+
-
+
### 煎蛋
diff --git a/router.js b/router.js
index 8e54fc992..ba3fc51a5 100644
--- a/router.js
+++ b/router.js
@@ -168,7 +168,7 @@ router.get('/zhihu/question/:questionId', require('./routes/zhihu/question'));
router.get('/zhihu/topic/:topicId', require('./routes/zhihu/topic'));
// 妹子图
-router.get('/mzitu', require('./routes/mzitu/category'));
+router.get('/mzitu/home/:type?', require('./routes/mzitu/home'));
router.get('/mzitu/tags', require('./routes/mzitu/tags'));
router.get('/mzitu/category/:category', require('./routes/mzitu/category'));
router.get('/mzitu/post/:id', require('./routes/mzitu/post'));
diff --git a/routes/mzitu/category.js b/routes/mzitu/category.js
index f838c5845..5080c241e 100644
--- a/routes/mzitu/category.js
+++ b/routes/mzitu/category.js
@@ -1,43 +1,40 @@
const axios = require('../../utils/axios');
-const cheerio = require('cheerio');
module.exports = async (ctx) => {
- let category = ctx.params.category;
-
- category = category === undefined || category === 'undefined' ? '' : category;
-
- const url = `http://www.mzitu.com/${category}`;
+ const { category } = ctx.params;
+ const mapper = {
+ xinggan: {
+ name: '性感妹子',
+ id: 4,
+ },
+ japan: {
+ name: '日本妹子',
+ id: 3,
+ },
+ taiwan: {
+ name: '台湾妹子',
+ id: 344,
+ },
+ mm: {
+ name: '清纯妹子',
+ id: 2,
+ },
+ };
+ const url = `http://adr.meizitu.net/wp-json/wp/v2/posts?categories=${mapper[category].id}&per_page=20`;
const response = await axios({
method: 'get',
- url: url,
- headers: {
- Referer: url,
- },
+ url,
});
-
const data = response.data;
- const $ = cheerio.load(data);
- const list = $('#pins li');
ctx.state.data = {
- title: $('title').text(),
- link: url,
- description: $('meta[name="description"]').attr('content') || $('title').text(),
- item:
- list &&
- list
- .map((item, index) => {
- item = $(index);
- const linkA = item.find('a');
- const previewImg = linkA.find('img');
- return {
- title: previewImg.attr('alt'),
- description: `描述:${previewImg.attr('alt')}
`,
- pubDate: new Date(item.find('.time').text()).toUTCString(),
- link: linkA.attr('href'),
- };
- })
- .get(),
+ title: `妹子图-${mapper[category].name}`,
+ link: `http://www.mzitu.com/${category}`,
+ item: data.map((item) => ({
+ title: item.title,
+ description: `
`,
+ link: `http://www.mzitu.com/${item.id}`,
+ })),
};
};
diff --git a/routes/mzitu/home.js b/routes/mzitu/home.js
new file mode 100644
index 000000000..321ffcda7
--- /dev/null
+++ b/routes/mzitu/home.js
@@ -0,0 +1,34 @@
+const axios = require('../../utils/axios');
+
+module.exports = async (ctx) => {
+ const { type = '' } = ctx.params;
+ let url;
+
+ if (type === 'hot') {
+ url = 'http://adr.meizitu.net/wp-json/wp/v2/hot';
+ } else {
+ url = 'http://adr.meizitu.net/wp-json/wp/v2/posts?per_page=20';
+ }
+
+ const response = await axios({
+ method: 'get',
+ url,
+ });
+ const data = response.data;
+
+ ctx.state.data = {
+ title: '妹子图',
+ link: `http://www.mzitu.com/${type}`,
+ item: data.map((item) => {
+ if (type === 'hot') {
+ item.thumb_src = item.thumb_src_min;
+ }
+
+ return {
+ title: item.title,
+ description: `
`,
+ link: `http://www.mzitu.com/${item.id}`,
+ };
+ }),
+ };
+};
diff --git a/routes/mzitu/post.js b/routes/mzitu/post.js
index 9084345e6..fd9765634 100644
--- a/routes/mzitu/post.js
+++ b/routes/mzitu/post.js
@@ -1,74 +1,35 @@
const axios = require('../../utils/axios');
-const cheerio = require('cheerio');
module.exports = async (ctx) => {
- const id = ctx.params.id;
+ const { id } = ctx.params;
- const url = `http://www.mzitu.com/${id}`;
+ const contentUrl = `http://adr.meizitu.net/wp-json/wp/v2/i?id=${id}`;
+ const postUrl = `http://adr.meizitu.net/wp-json/wp/v2/posts/${id}`;
+ const link = `http://www.mzitu.com/${id}`;
- const response = await axios({
+ const contentResponse = await axios({
method: 'get',
- url: url,
- headers: {
- Referer: url,
- },
+ url: contentUrl,
});
+ const content = contentResponse.data.content.split(',');
- const data = response.data;
- const $ = cheerio.load(data);
-
- const img = $('.main-image > p > a > img');
- const imgUrl = img.attr('src');
-
- const prefix = imgUrl.substr(0, imgUrl.lastIndexOf('01.'));
- const suffix = imgUrl.substr(imgUrl.lastIndexOf('.'));
-
- let totalPage = $('.pagenavi > a:nth-last-child(2)')
- .find('span')
- .text();
- totalPage = +totalPage;
-
- const list = [
- {
- url,
- imgUrl,
- page: 1,
- },
- ];
- for (let i = 2; i <= totalPage; i++) {
- const p = i < 10 ? `0${i}` : i;
- const nextImgUrl = `${prefix}${p}${suffix}`;
- const nextUrl = `${url}/${i}`;
- list.push({
- url: nextUrl,
- imgUrl: nextImgUrl,
- page: i,
- });
- }
-
- const title = $('title').text();
-
- const reg = /[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d/;
+ const postResponse = await axios({
+ method: 'get',
+ url: postUrl,
+ });
+ const { title } = postResponse.data;
ctx.state.data = {
title: title,
- link: url,
- description: $('meta[name="description"]').attr('content') || title,
- item:
- list &&
- list.map((item) => {
- let date = new Date();
- const dateStr = $('.main-meta > span:nth-child(2)').text();
- if (reg.test(dateStr)) {
- date = new Date(dateStr.match(reg)[0]);
- }
+ link,
+ item: content.map((url, index) => {
+ url = url.replace(/"/g, '');
- return {
- title: `${title}(${item.page})`,
- description: `分类:${$('.main-meta > span:nth-child(1) > a').text()}
描述:${title}(${item.page})
`,
- pubDate: date.toUTCString(),
- link: item.url,
- };
- }),
+ return {
+ title: `${title}(${index + 1})`,
+ description: `
`,
+ link: url,
+ };
+ }),
};
};
diff --git a/routes/mzitu/tag.js b/routes/mzitu/tag.js
index 3ac562e21..bce06721b 100644
--- a/routes/mzitu/tag.js
+++ b/routes/mzitu/tag.js
@@ -1,42 +1,30 @@
const axios = require('../../utils/axios');
-const cheerio = require('cheerio');
module.exports = async (ctx) => {
let tag = ctx.params.tag;
tag = tag === undefined || tag === 'undefined' ? '' : tag;
- const url = `http://www.mzitu.com/tag/${tag}`;
-
- const response = await axios({
+ const tagsUrl = `http://adr.meizitu.net/wp-json/wp/v2/tags?slug=${tag}`;
+ const tagsResponse = await axios({
method: 'get',
- url: url,
- headers: {
- Referer: url,
- },
+ url: tagsUrl,
});
+ const { id, name } = tagsResponse.data[0] || {};
- const data = response.data;
- const $ = cheerio.load(data);
- const list = $('#pins li');
+ const tagUrl = `http://adr.meizitu.net/wp-json/wp/v2/posts?tags=${id}&per_page=20`;
+ const tagResponse = await axios({
+ method: 'get',
+ url: tagUrl,
+ });
+ const data = tagResponse.data;
ctx.state.data = {
- title: $('title').text(),
- link: url,
- description: $('meta[name="description"]').attr('content') || $('title').text(),
- item:
- list &&
- list
- .map((item, index) => {
- item = $(index);
- const linkA = item.find('a');
- const previewImg = linkA.find('img');
- return {
- title: previewImg.attr('alt'),
- description: `描述:${previewImg.attr('alt')}
`,
- pubDate: new Date(item.find('.time').text()).toUTCString(),
- link: linkA.attr('href'),
- };
- })
- .get(),
+ title: name,
+ link: `http://www.mzitu.com/tag/${tag}`,
+ item: data.map((item) => ({
+ title: item.title,
+ description: `
`,
+ link: `http://www.mzitu.com/${item.id}`,
+ })),
};
};
diff --git a/routes/mzitu/tags.js b/routes/mzitu/tags.js
index 572418989..3637fef20 100644
--- a/routes/mzitu/tags.js
+++ b/routes/mzitu/tags.js
@@ -1,39 +1,22 @@
const axios = require('../../utils/axios');
-const cheerio = require('cheerio');
module.exports = async (ctx) => {
- const url = 'http://www.mzitu.com/zhuanti';
+ const url = 'http://adr.meizitu.net/wp-json/wp/v2/tags?orderby=count&order=desc&per_page=100';
const response = await axios({
method: 'get',
url: url,
- headers: {
- Referer: url,
- },
});
-
const data = response.data;
- const $ = cheerio.load(data);
- const list = $('.main-content > div.postlist > dl > dd');
ctx.state.data = {
- title: $('title').text(),
- link: url,
- description: $('meta[name="description"]').attr('content') || $('title').text(),
- item:
- list &&
- list
- .map((item, index) => {
- item = $(index);
- const linkA = item.find('a');
- const previewImg = linkA.find('img');
- return {
- title: previewImg.attr('alt'),
- description: `${item.find('i').text()}
描述:${previewImg.attr('alt')}
`,
- pubDate: '',
- link: linkA.attr('href'),
- };
- })
- .get(),
+ title: '妹子图专题',
+ link: 'http://www.mzitu.com/zhuanti',
+ description: '妹子图美女专题栏目,为您精心准备各种美女图片专题,包括名站美女写真,妹子特点分类,美女大全等专题。',
+ item: data.map((item) => ({
+ title: item.name,
+ description: `${item.name}`,
+ link: `http://www.mzitu.com/tag/${item.slug}`,
+ })),
};
};