|
1 | | -import { ObjType } from '@/type'; |
2 | | -import { getHtml } from '@/utils/lib'; |
3 | | -import { MAX_DESC_LENGTH } from '@/utils/static'; |
4 | | -import * as cheerio from 'cheerio'; |
| 1 | +import { ObjType } from "@/type"; |
| 2 | +import { getHtml } from "@/utils/lib"; |
| 3 | +import { MAX_DESC_LENGTH } from "@/utils/static"; |
| 4 | +import * as cheerio from "cheerio"; |
5 | 5 |
|
6 | 6 | export const getKFAList = async () => { |
7 | | - const kfa = 'https://kofearticle.substack.com'; |
8 | | - const kfaTitle = '[Korean FE Article]'; |
| 7 | + const kfa = "https://kofearticle.substack.com"; |
| 8 | + const kfaTitle = "[Korean FE Article]"; |
9 | 9 | const result: ObjType[] = []; |
10 | 10 | const html = await getHtml(kfa); |
11 | 11 | const $ = cheerio.load(html?.data); |
12 | | - const $bodyList = $('div.home-page .post-preview-content'); |
| 12 | + const $bodyList = $( |
| 13 | + "div.portable-archive-list > div > div > div.pencraft > div.pencraft > div.pencraft" |
| 14 | + ); |
13 | 15 |
|
14 | 16 | $bodyList.each((i, elem) => { |
15 | 17 | result.push({ |
16 | | - title: $(elem).find('a.post-preview-title').text().replace(kfaTitle, ''), |
17 | | - desc: $(elem).find('a.post-preview-description').text().slice(0, MAX_DESC_LENGTH) + '...', |
18 | | - url: '' + $(elem).find('a.post-preview-title').attr('href'), |
| 18 | + title: $(elem) |
| 19 | + .find(".pencraft > .pencraft:nth-child(1) a") |
| 20 | + .text() |
| 21 | + .replace(kfaTitle, ""), |
| 22 | + desc: |
| 23 | + $(elem) |
| 24 | + .find(".pencraft > .pencraft:nth-child(2) a") |
| 25 | + .text() |
| 26 | + .slice(0, MAX_DESC_LENGTH) + "...", |
| 27 | + url: |
| 28 | + "" + $(elem).find(".pencraft > .pencraft:nth-child(1) a").attr("href"), |
19 | 29 | }); |
20 | 30 | }); |
21 | 31 |
|
|
0 commit comments