1. 가상환경 생성 및 라이브러리 설치 (conda activate 제발 먼저 하자)
- Elasticsearch 로컬 다운로드
Download Elasticsearch
Download Elasticsearch or the complete Elastic Stack (formerly ELK stack) for free and start searching and analyzing in minutes with Elastic....
www.elastic.co
conda create -n ainews python>=3.12
conda activate ainews
# fastapi 관련
pip install fastapi pydantic uvicorn
# elastic 관련
pip install elasticsearch
# airflow 관련
mkdir airflow && cd airflow
pip install apache-airflow
2. 폴더 구조 생성
- 각각 별도의 폴더를 구성하고, 각자가 하는 일은 해당 폴더 내에서 이루어질 수 있도록 한다.
│ .env
│ .gitignore
│ README.md
│
├───airflow
├───backend
│ │ news_main.py
│ │
│ ├───services
│ │ │ newsapi.py
│
├───data
└───elastic
│ article_to_es.py
└── es_client.py
3. 뉴스 API 파일 생성
News API – Search News and Blog Articles on the Web
“Ascender AI has a mission to apply AI to the media, and NewsAPI is one of our most valuable resources. Ascender is redefining how users interact with complex information, and the NewsAPI feed is an essential showcase for our technologies.” Braddock Ga
newsapi.org
import requests
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.environ.get('API_KEY')
KEYWORD = "AI"
def get_articles():
url = ('https://newsapi.org/v2/top-headlines?'
f'q={KEYWORD}&'
'sortBy=publishedAt&' # 기사 업로드 순
f'apiKey={API_KEY}')
response = requests.get(url)
return response.json()
'ML_DL > MUJAKJUNG (무작정 시리즈)' 카테고리의 다른 글
Elasticsearch, Airflow 활용하기 - 3. Airflow 환경설정 (0) | 2025.03.04 |
---|---|
Elasticsearch, Airflow 활용하기 - 2. Elasticsearch 설정 (0) | 2025.03.03 |
이미지 분류 모델 작성하기 (feat. wandb) (0) | 2025.02.19 |
프로젝트 업그레이드 1탄 - 프로젝트 생성 (0) | 2025.02.06 |
[Llama3 파인튜닝] 코드 업데이트 및 실험 2 (0) | 2024.12.25 |