Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): add Resonac #16960

Merged
merged 61 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
82bd10f
Create namespace.ts
valuex Sep 23, 2024
f22447a
Add files via upload
valuex Sep 23, 2024
938a361
Update dongtai.ts
valuex Sep 23, 2024
7f902a9
Update gonggao.ts
valuex Sep 23, 2024
a2787c8
Update gonggao.ts
valuex Sep 23, 2024
23935ef
Update gonggao.ts
valuex Sep 23, 2024
08eb02a
Update dongtai.ts
valuex Sep 23, 2024
3eb2e2c
Update gonggao.ts
valuex Sep 23, 2024
7839b33
Update gonggao.ts
valuex Sep 23, 2024
4c47d14
Update gonggao.ts
valuex Sep 23, 2024
0d9aa20
Update gonggao.ts
valuex Sep 23, 2024
e405bd5
Update dongtai.ts
valuex Sep 23, 2024
749f85f
Merge branch 'DIYgod:master' into master
valuex Sep 23, 2024
076da3f
Create namespace.ts
valuex Sep 23, 2024
d4e65e0
Add files via upload
valuex Sep 23, 2024
5cc7b45
Update articles.ts
valuex Sep 23, 2024
4960c8d
Update articles.ts
valuex Sep 23, 2024
b535220
Update articles.ts
valuex Sep 23, 2024
ab5fc1d
Update articles.ts
valuex Sep 23, 2024
b3568da
Update articles.ts
valuex Sep 23, 2024
22d6a22
Update articles.ts
valuex Sep 23, 2024
7dea935
Update articles.ts
valuex Sep 23, 2024
8ddd326
route for 日经新闻半导体,产业聚焦
valuex Sep 23, 2024
054d0d7
Merge branch 'DIYgod:master' into master
valuex Sep 23, 2024
e0d6062
Update scienceatechnology.ts
valuex Sep 23, 2024
bafd749
Update semi.ts
valuex Sep 23, 2024
77148ef
Merge branch 'DIYgod:master' into master
valuex Sep 24, 2024
c9f41ba
Delete lib/routes/yamap directory
valuex Sep 24, 2024
114b55b
Delete lib/routes/nikkei/semi.ts
valuex Sep 24, 2024
a34ef4d
Delete lib/routes/nikkei/scienceatechnology.ts
valuex Sep 24, 2024
7fc1c85
Update lib/routes/szftedu/dongtai.ts
valuex Sep 25, 2024
a0e1b17
Update lib/routes/szftedu/namespace.ts
valuex Sep 25, 2024
fdfbbea
Update lib/routes/szftedu/gonggao.ts
valuex Sep 25, 2024
a3dc5ea
Update gonggao.ts
valuex Sep 25, 2024
11ea30a
Update gonggao.ts
valuex Sep 25, 2024
a86a0a9
Update dongtai.ts
valuex Sep 25, 2024
3071a1f
Update gonggao.ts
valuex Sep 25, 2024
f0a47e8
Update gonggao.ts
valuex Sep 25, 2024
bb072fe
Update dongtai.ts
valuex Sep 25, 2024
e924535
Update dongtai.ts
valuex Sep 25, 2024
7934c0f
Update dongtai.ts
valuex Sep 25, 2024
9ffc5c4
Update gonggao.ts
valuex Sep 25, 2024
2bbf4b4
Update lib/routes/szftedu/gonggao.ts
valuex Sep 26, 2024
472b67a
Update lib/routes/szftedu/dongtai.ts
valuex Sep 26, 2024
aa317e2
Update dongtai.ts
valuex Sep 26, 2024
448df3d
Update dongtai.ts
valuex Sep 28, 2024
a5ba5b7
Merge branch 'DIYgod:master' into master
valuex Sep 28, 2024
091394e
Merge branch 'DIYgod:master' into master
valuex Sep 28, 2024
391af31
fix: route name
TonyRL Sep 28, 2024
ea081bb
new route: resonac products
valuex Sep 29, 2024
81c0f7c
Merge branch 'master' of https://github.com/valuex/RSSHub
valuex Sep 29, 2024
9ab8ff4
Merge branch 'DIYgod:master' into master
valuex Sep 29, 2024
b103bf9
Update products.ts
valuex Sep 29, 2024
41c376c
Merge branch 'master' of https://github.com/valuex/RSSHub
valuex Sep 29, 2024
1f81b22
Update products.ts
valuex Sep 29, 2024
00f3246
Update products.ts
valuex Sep 29, 2024
2291b83
Update products.ts
valuex Sep 29, 2024
7877a93
fix: names
TonyRL Oct 4, 2024
5eb2ad2
fix: remove fake pubDate
TonyRL Oct 4, 2024
c6c7bd1
fix: remove unecessary spaces in selectors
TonyRL Oct 4, 2024
1ff8c03
fix: selectors
TonyRL Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/routes/resonac/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Resonac',
url: 'www.resonac.com',
};
85 changes: 85 additions & 0 deletions lib/routes/resonac/products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
// import { parseDate } from '@/utils/parse-date';
// import timezone from '@/utils/timezone';

const baseUrl = 'https://www.resonac.com';
const host = 'https://www.resonac.com/products?intcid=glnavi_products';

export const route: Route = {
path: '/products',
categories: ['other'],
example: '/resonac/products',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Products',
maintainers: ['valuex'],
handler,
description: '',
};

async function handler() {
const response = await got(host);
const pageHtml = response.data;
const $ = load(pageHtml);
const groupLists = $('div.m-panel-card-link ul li')
.toArray()
.map((el) => ({
groupName: $('a', el).text().trim(),
groupURL: baseUrl + $('a', el).attr('href'),
}));

const lists = await Promise.all(
groupLists.map((productGroup) =>
cache.tryGet(productGroup.groupURL, async () => {
const strUrl = productGroup.groupURL;
const response = await got(strUrl);
const $ = load(response.data);
const item = $('dt.m-toggle__title div span a')
.toArray()
.map((el) => ({
title: $('b', el).text().trim(),
link: baseUrl + $(el).attr('href'),
group: productGroup.groupName,
}));
return item;
})
)
);

const fullList = lists.flat(1); // flatten array
// fullList = fullList.filter((item) => item.title !== 'Empty');

const items = await Promise.all(
fullList.map((item) =>
cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const $ = load(response.data);
const thisTitle = item.title + ' | ' + item.group;
item.title = thisTitle;
item.description = $('main div.str-section').html();
return item;
} catch (error) {
return (error as Error).message;
}
})
)
);

return {
title: 'Resonac_Products',
link: baseUrl,
description: 'Resonac_Products',
item: items,
};
}