Skip to content

Commit b9f51e5

Browse files
author
harry-yoon
committed
πŸ”§ kfa 크둀링 정상 λ™μž‘ν•˜λ„λ‘ μˆ˜μ •
1 parent d3c9633 commit b9f51e5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

β€Žsrc/korean-fe-article/index.tsβ€Ž

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
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";
55

66
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]";
99
const result: ObjType[] = [];
1010
const html = await getHtml(kfa);
1111
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+
);
1315

1416
$bodyList.each((i, elem) => {
1517
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"),
1929
});
2030
});
2131

0 commit comments

Comments
Β (0)