mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 10:15:23 +08:00
feat(route): add fashion network news (#7602)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -221,6 +221,74 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Fashion Network
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="nczitzk" example="/fashionnetwork/news/5,6/15,112" path="/fashionnetwork/news/:sectors?/:categories?/:country?" :paramsDesc="['Sectors, see below, `all` by default', 'Categories, see below, `all` by default', 'Country, see below, `ww` as Worldwide by default']">
|
||||
|
||||
Sectoies
|
||||
|
||||
Fashion 1
|
||||
|
||||
| Ready-to-wear | Accessories | Footwear | Sports | Denim | Lingerie | Swimwear | Eyewear | Bridal wear | Textile | Miscellaneous |
|
||||
| ------------- | ----------- | -------- | ------ | ----- | -------- | -------- | ------- | ----------- | ------- | ------------- |
|
||||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 31 |
|
||||
|
||||
Luxury 2
|
||||
|
||||
| Ready-to-wear | Accessories | Footwear | Watches | Jewellery | Miscellaneous |
|
||||
| ------------- | ----------- | -------- | ------- | --------- | ------------- |
|
||||
| 15 | 16 | 17 | 18 | 19 | 32 |
|
||||
|
||||
Beauty 3
|
||||
|
||||
| Perfume | Cosmetics | Aesthetics | Wellness | Hair | Miscellaneous |
|
||||
| ------- | --------- | ---------- | -------- | ---- | ------------- |
|
||||
| 21 | 22 | 23 | 24 | 33 | |
|
||||
|
||||
Lifestyle 4
|
||||
|
||||
| Home decor | Tableware | Hospitality | Fine foods | Tourism | Miscellaneous |
|
||||
| ---------- | --------- | ----------- | ---------- | ------- | ------------- |
|
||||
| 25 | 26 | 27 | 28 | 29 | 34 |
|
||||
|
||||
Others 30
|
||||
|
||||
Category
|
||||
|
||||
| Retail | Business | Industry | Trade shows |
|
||||
| ------ | -------- | -------- | ----------- |
|
||||
| 15 | 112 | 5 | 12 |
|
||||
|
||||
| Innovations | Collection | Catwalks | Design |
|
||||
| ----------- | ---------- | -------- | ------ |
|
||||
| 113 | 114 | 60 | 70 |
|
||||
|
||||
| Media | Campaigns | People | Events | Appointments |
|
||||
| ----- | --------- | ------ | ------ | ------------ |
|
||||
| 50 | 115 | 80 | 90 | 95 |
|
||||
|
||||
Country
|
||||
|
||||
| Latin America | Brazil | China | France |
|
||||
| ------------- | ------ | ----- | ------ |
|
||||
| pe | br | cn | fr |
|
||||
|
||||
| Germany | India | Italy | Japan |
|
||||
| ------- | ----- | ----- | ----- |
|
||||
| de | in | it | jp |
|
||||
|
||||
| Mexico | Portugal | Russia | Spain |
|
||||
| ------ | -------- | ------ | ----- |
|
||||
| mx | pt | ru | es |
|
||||
|
||||
| Turkey | United Kingdom | USA | Worldwide |
|
||||
| ------ | -------------- | --- | --------- |
|
||||
| tr | uk | us | ww |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Fermilab
|
||||
|
||||
### News
|
||||
|
||||
@@ -306,6 +306,74 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## Fashion Network
|
||||
|
||||
### News
|
||||
|
||||
<Route author="nczitzk" example="/fashionnetwork/news/5,6/15,112" path="/fashionnetwork/news/:sectors?/:categories?/:country?" :paramsDesc="['分区,见下表,默认为 `all`', '分类,见下表,默认为 `all`', '国家,见下表,默认为 `ww`']">
|
||||
|
||||
Sectoies
|
||||
|
||||
Fashion 1
|
||||
|
||||
| Ready-to-wear | Accessories | Footwear | Sports | Denim | Lingerie | Swimwear | Eyewear | Bridal wear | Textile | Miscellaneous |
|
||||
| ------------- | ----------- | -------- | ------ | ----- | -------- | -------- | ------- | ----------- | ------- | ------------- |
|
||||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 31 |
|
||||
|
||||
Luxury 2
|
||||
|
||||
| Ready-to-wear | Accessories | Footwear | Watches | Jewellery | Miscellaneous |
|
||||
| ------------- | ----------- | -------- | ------- | --------- | ------------- |
|
||||
| 15 | 16 | 17 | 18 | 19 | 32 |
|
||||
|
||||
Beauty 3
|
||||
|
||||
| Perfume | Cosmetics | Aesthetics | Wellness | Hair | Miscellaneous |
|
||||
| ------- | --------- | ---------- | -------- | ---- | ------------- |
|
||||
| 21 | 22 | 23 | 24 | 33 | |
|
||||
|
||||
Lifestyle 4
|
||||
|
||||
| Home decor | Tableware | Hospitality | Fine foods | Tourism | Miscellaneous |
|
||||
| ---------- | --------- | ----------- | ---------- | ------- | ------------- |
|
||||
| 25 | 26 | 27 | 28 | 29 | 34 |
|
||||
|
||||
Others 30
|
||||
|
||||
Category
|
||||
|
||||
| Retail | Business | Industry | Trade shows |
|
||||
| ------ | -------- | -------- | ----------- |
|
||||
| 15 | 112 | 5 | 12 |
|
||||
|
||||
| Innovations | Collection | Catwalks | Design |
|
||||
| ----------- | ---------- | -------- | ------ |
|
||||
| 113 | 114 | 60 | 70 |
|
||||
|
||||
| Media | Campaigns | People | Events | Appointments |
|
||||
| ----- | --------- | ------ | ------ | ------------ |
|
||||
| 50 | 115 | 80 | 90 | 95 |
|
||||
|
||||
Country
|
||||
|
||||
| Latin America | Brazil | China | France |
|
||||
| ------------- | ------ | ----- | ------ |
|
||||
| pe | br | cn | fr |
|
||||
|
||||
| Germany | India | Italy | Japan |
|
||||
| ------- | ----- | ----- | ----- |
|
||||
| de | in | it | jp |
|
||||
|
||||
| Mexico | Portugal | Russia | Spain |
|
||||
| ------ | -------- | ------ | ----- |
|
||||
| mx | pt | ru | es |
|
||||
|
||||
| Turkey | United Kingdom | USA | Worldwide |
|
||||
| ------ | -------------- | --- | --------- |
|
||||
| tr | uk | us | ww |
|
||||
|
||||
</Route>
|
||||
|
||||
## Focus Taiwan
|
||||
|
||||
### Category
|
||||
|
||||
@@ -4220,4 +4220,7 @@ router.get('/rss3/blog', require('./routes/rss3/blog'));
|
||||
// 星球日报
|
||||
router.get('/odaily/activity', require('./routes/odaily/activity'));
|
||||
|
||||
// Fashion Network
|
||||
router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', require('./routes/fashionnetwork/news.js'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
70
lib/routes/fashionnetwork/news.js
Normal file
70
lib/routes/fashionnetwork/news.js
Normal file
@@ -0,0 +1,70 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const country = ctx.params.country || 'ww';
|
||||
let sectors = ctx.params.sectors || '';
|
||||
let categories = ctx.params.categories || '';
|
||||
|
||||
sectors = sectors === 'all' ? '' : sectors;
|
||||
categories = categories === 'all' ? '' : categories;
|
||||
|
||||
const sectorsUrl = sectors ? 'sectors%5B%5D=' + sectors.split(',').join('§ors%5B%5D=') : '';
|
||||
const categoriesUrl = categories ? 'categs%5B%5D=' + categories.split(',').join('&categs%5B%5D=') : '';
|
||||
|
||||
const rootUrl = `https://${country}.fashionnetwork.com`;
|
||||
const currentUrl = `${rootUrl}/news/s.jsonp?${sectorsUrl}&${categoriesUrl}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(
|
||||
unescape(response.data.match(/"html":"(.*)","relatedUrl"/)[1].replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1'))
|
||||
.replace(/\\n/g, '')
|
||||
.replace(/\\\//g, '/')
|
||||
);
|
||||
|
||||
const list = $('.list-ui__title')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
pubDate: Date.parse(item.parent().find('time').attr('datetime')),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.newsTitle, .ads').remove();
|
||||
|
||||
item.description = content('div[itemprop="text"]').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const labels = [];
|
||||
|
||||
$('.filter__label').each(function () {
|
||||
labels.push($(this).text());
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${labels.join(',') || 'All'} - FashionNetwork`,
|
||||
link: `${rootUrl}/news/s?${sectorsUrl}&${categoriesUrl}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user