
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
GPT에서 질문 여러번 바꿔가며 코드를 달리 해봤는데 계속 1초만에 실행이 끝나지만 아무것도 출력이 되지 않습니다.
혹시 왜 이러는 건지 알수 있을까요

작성한 코드 및 에러 메세지
import requests
from bs4 import BeautifulSoup
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
def get_news_headlines(query, num_headlines=5):
url = f"https://search.naver.com/search.naver?where=news&query={query}&sm=tab_opt&sort=0&photo=0&field=0&reporter_article=&pd=3&ds=2022.01.01&de=2023.12.31&docid=&nso=so%3Ar%2Cp%3Afrom20220101to20231231%2Ca%3Aall&mynews=1&cluster_rank=29&start=1"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
headlines = []
for i, news_item in enumerate(soup.select('.news_tit')):
if i >= num_headlines:
break
headlines.append(news_item.get_text(strip=True))
return headlines
def perform_sentiment_analysis(headlines):
analyzer = SentimentIntensityAnalyzer()
for i, headline in enumerate(headlines):
sentiment_score = analyzer.polarity_scores(headline)['compound']
print(f"\nHeadline {i + 1}: {headline}")
print(f"Sentiment Score: {sentiment_score}")
if sentiment_score >= 0.05:
print("Sentiment: Positive")
elif sentiment_score <= -0.05:
print("Sentiment: Negative")
else:
print("Sentiment: Neutral")
if __name__ == "__main__":
search_query = "samsung electronics"
num_headlines_to_scrape = 5
news_headlines = get_news_headlines(search_query, num_headlines_to_scrape)
perform_sentiment_analysis(news_headlines)
