Skip to content

Commit

Permalink
πŸ”§ kfa 크둀링 정상 λ™μž‘ν•˜λ„λ‘ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-yoon committed May 30, 2023
1 parent d3c9633 commit b9f51e5
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/korean-fe-article/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import { ObjType } from '@/type';
import { getHtml } from '@/utils/lib';
import { MAX_DESC_LENGTH } from '@/utils/static';
import * as cheerio from 'cheerio';
import { ObjType } from "@/type";
import { getHtml } from "@/utils/lib";
import { MAX_DESC_LENGTH } from "@/utils/static";
import * as cheerio from "cheerio";

export const getKFAList = async () => {
const kfa = 'https://kofearticle.substack.com';
const kfaTitle = '[Korean FE Article]';
const kfa = "https://kofearticle.substack.com";
const kfaTitle = "[Korean FE Article]";
const result: ObjType[] = [];
const html = await getHtml(kfa);
const $ = cheerio.load(html?.data);
const $bodyList = $('div.home-page .post-preview-content');
const $bodyList = $(
"div.portable-archive-list > div > div > div.pencraft > div.pencraft > div.pencraft"
);

$bodyList.each((i, elem) => {
result.push({
title: $(elem).find('a.post-preview-title').text().replace(kfaTitle, ''),
desc: $(elem).find('a.post-preview-description').text().slice(0, MAX_DESC_LENGTH) + '...',
url: '' + $(elem).find('a.post-preview-title').attr('href'),
title: $(elem)
.find(".pencraft > .pencraft:nth-child(1) a")
.text()
.replace(kfaTitle, ""),
desc:
$(elem)
.find(".pencraft > .pencraft:nth-child(2) a")
.text()
.slice(0, MAX_DESC_LENGTH) + "...",
url:
"" + $(elem).find(".pencraft > .pencraft:nth-child(1) a").attr("href"),
});
});

Expand Down

0 comments on commit b9f51e5

Please sign in to comment.