랭그래프 활용한 주식 정보 도출 프로젝트
- yahooquery, ta 라이브러리 활용
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from langchain_community.utilities import GoogleSerperAPIWrapper
|
||||
|
||||
from backend.schemas.news_schemas import NewsItem
|
||||
|
||||
|
||||
async def get_news(company_name: str):
|
||||
"""
|
||||
구글 뉴스 검색 후
|
||||
title, snippet, url, source, date 추출
|
||||
"""
|
||||
search = GoogleSerperAPIWrapper(type="news")
|
||||
results = await search.results(f"{company_name} stock news")
|
||||
news_list = []
|
||||
|
||||
for item in results['news'][:10]:
|
||||
news_list.append(
|
||||
NewsItem(
|
||||
title=item.get("title", ""),
|
||||
snippet=item.get("snippet", ""),
|
||||
url=item.get("link", ""),
|
||||
source=item.get("source", ""),
|
||||
date=item.get("date", "")
|
||||
)
|
||||
)
|
||||
|
||||
return news_list
|
||||
Reference in New Issue
Block a user