Data Science Project

[Newspelling] 뉴스 키워드 추출 프로젝트 - 문제정의 및 데이터 수집

ParkS2 2025. 3. 9. 02:03

문제정의

 

키워드의 이해 / 키워드 맥락 부분의 문제 해결 필요

 

 

데이터 수집

실시간 데이터를 수집하기 위해, RSS URL을 통해서 뉴스 텍스트 데이터 수집을 진행한다.

 

RSS의 네트워크는 3개의 주용한 컴포넌트로 구성이 되어져 있다.

 

1)컨텐츠 제공자 (Content Provider)는 각 제공 뉴스 정보와 자신의 정보에 관한 RSS 파일을제공한다.

2)수집자 (Content Aggregator)는 다양한 경로를 통해 RSS 정보를읽거나 수집하는 콘텐츠 수집자 (Content Aggregator)로서 인덱스를 수집하고 그 인덱스를 통해 화제가 되는 특정 뉴스의 헤드라인을 수집하고 제공한다.

3)헤드라인 뷰어 (Headline Viewer)는 이용자가 RSS 리더 프로그램을 통하며 콘텐츠를 제공 받고 읽을 수 있다.

 

RSS URL 를 통한 뉴스 데이터 수집

 

전체
https://news.sbs.co.kr/news/headlineRssFeed.do?plink=RSSREADER https://news.sbs.co.kr/news/TopicRssFeed.do?plink=RSSREADER

정치
https://www.yna.co.kr/rss/politics.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/10 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=01&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/politics/?outputType=xml https://www.hankyung.com/feed/politics

경제
https://www.yna.co.kr/rss/economy.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/20 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=02&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/economy/?outputType=xml https://www.hankyung.com/feed/economy

사회
https://www.yna.co.kr/rss/society.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/30 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=03&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/national/?outputType=xml https://www.hankyung.com/feed/society

세계
https://www.yna.co.kr/rss/international.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/40 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=07&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/international/?outputType=xml https://www.hankyung.com/feed/international

문화
https://www.yna.co.kr/rss/culture.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/50 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=08&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/culture-life/?outputType=xml https://www.hankyung.com/feed/life

연예
https://www.yna.co.kr/rss/entertainment.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/60 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=14&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/entertainments/?outputType=xml https://www.hankyung.com/feed/entertainment

스포츠
https://www.yna.co.kr/rss/sports.xml https://news-ex.jtbc.co.kr/v1/get/rss/section/70 https://news.sbs.co.kr/news/SectionRssFeed.do?sectionId=09&plink=RSSREADER https://www.chosun.com/arc/outboundfeeds/rss/category/sports/?outputType=xml https://www.hankyung.com/feed/sports

 

RSS 파싱

  • RSS 파싱이란, 웹사이트가 제공하는 RSS(Really Simple Syndication) 형태의 데이터를 읽어와서 사용하기 쉽게 제목, 링크, 발행일 등으로 나누어 정리하는 작업.
  • 주로 feedparser와 같은 파싱 라이브러리를 사용해 뉴스, 블로그 등의 최신 정보를 빠르게 수집할 때 쓰인다.
# RSS 데이터 파싱 함수
def parse_rss(url):
    feed = feedparser.parse(url)
    return [
        {
            "제목": entry.title if hasattr(entry, 'title') else '',
            "링크": entry.link if hasattr(entry, 'link') else '',
            "발행일": entry.get("published", None)
        }
        for entry in feed.entries
    ]
rss_urls = RSS_FEEDS[category]
    all_news = []
    for url in rss_urls:
        all_news.extend(parse_rss(url))

 

 

  • RSS_FEEDS 딕셔너리: 다양한 뉴스 카테고리(예: 정치, 경제 등)에 해당하는 RSS URL 목록을 미리 정의
  • parse_rss 함수: 각 RSS URL을 feedparser로 파싱해, 기사 제목, 링크, 발행일 등의 정보를 딕셔너리 형태로 추출
  • 데이터 통합: 여러 RSS 피드에서 수집한 기사를 리스트에 모은 후, Pandas DataFrame으로 변환해 후속 처리(텍스트 전처리, 키워드 추출 등)에 사용