diff --git a/clis/aibase/news.js b/clis/aibase/news.js new file mode 100644 index 00000000..f907b710 --- /dev/null +++ b/clis/aibase/news.js @@ -0,0 +1,40 @@ +/** + * aibase news adapter + * + * Fetches the latest AI industry daily news from AIbase (日报). + * Scrapes article links from aibase.com/zh/daily. + * + * Usage: + * opencli aibase news + * opencli aibase news --limit 10 + */ +import { cli, Strategy } from '@jackwener/opencli/registry'; + +cli({ + site: 'aibase', + name: 'news', + description: 'AIbase 日报 - 每天三分钟关注AI行业趋势', + domain: 'www.aibase.com', + strategy: Strategy.PUBLIC, + browser: true, + args: [ + { name: 'limit', type: 'int', default: 20, help: 'Number of news items to return' }, + ], + columns: ['rank', 'title', 'url'], + pipeline: [ + { navigate: 'https://www.aibase.com/zh/daily' }, + { + evaluate: ` + const items = Array.from( + document.querySelectorAll('.bg-white .grid a') + ).filter(el => el.href && el.textContent.trim()); + return items.map((el, i) => ({ + rank: i + 1, + title: el.textContent.trim(), + url: el.href, + })); + `, + }, + { limit: '${{ args.limit }}' }, + ], +}); diff --git a/clis/uisdc/news.js b/clis/uisdc/news.js new file mode 100644 index 00000000..ae5d496f --- /dev/null +++ b/clis/uisdc/news.js @@ -0,0 +1,43 @@ +/** + * uisdc news adapter + * + * Fetches the latest AI/design industry news from 优设读报 (uisdc.com/news). + * Uses browser scraping via CSS selectors on the news list. + * + * Usage: + * opencli uisdc news + * opencli uisdc news --limit 10 + */ +import { cli, Strategy } from '@jackwener/opencli/registry'; + +cli({ + site: 'uisdc', + name: 'news', + description: '优设读报 - 最新 AI/设计行业新闻', + domain: 'www.uisdc.com', + strategy: Strategy.PUBLIC, + browser: true, + args: [ + { name: 'limit', type: 'int', default: 20, help: 'Number of news items to return' }, + ], + columns: ['rank', 'title', 'summary'], + pipeline: [ + { navigate: 'https://www.uisdc.com/news' }, + { + evaluate: ` + const items = Array.from( + document.querySelectorAll( + '.news-list > .news-item:first-child > .item-content > .dubao-items > .dubao-item' + ) + ); + return items.map((el, i) => ({ + rank: i + 1, + title: el.querySelector('.dubao-title')?.textContent?.trim() ?? '', + summary: el.querySelector('.dubao-content')?.textContent?.trim() ?? '', + url: el.querySelector('a')?.href ?? '', + })); + `, + }, + { limit: '${{ args.limit }}' }, + ], +});