From 50575e8d6155efe0ecebe1cb332c73849aaa60ab Mon Sep 17 00:00:00 2001 From: Yanzhen <34119752+imyanzhen@users.noreply.github.com> Date: Thu, 13 Apr 2023 18:40:38 +0800 Subject: [PATCH] Update SentimentAnalysis_part2.py Debug the code to reflect the changes in the latest HTML when crawling data from https://site.financialmodelingprep.com/ --- Sentiment Analysis/SentimentAnalysis_part2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sentiment Analysis/SentimentAnalysis_part2.py b/Sentiment Analysis/SentimentAnalysis_part2.py index bfaeb6c..c276525 100644 --- a/Sentiment Analysis/SentimentAnalysis_part2.py +++ b/Sentiment Analysis/SentimentAnalysis_part2.py @@ -16,7 +16,7 @@ print(request.text) parser = BeautifulSoup(request.text, "html.parser") -news_html = parser.find_all('a', {'class': 'article-item'}) +news_html = parser.find_all('a', {'class': 'article'}) print(news_html[0]) sentiments = [] @@ -24,9 +24,9 @@ sentiments.append( { 'ticker': ticker, - 'date': news_html[i].find('h5', {'class': 'article-date'}).text, - 'title': news_html[i].find('h4', {'class': 'article-title'}).text, - 'text': news_html[i].find('p', {'class': 'article-text'}).text + 'date': news_html[i].find('h5', {'class': 'article__date'}).text, + 'title': news_html[i].find('h4', {'class': 'article__title-text'}).text, + 'text': news_html[i].find('p', {'class': 'article__text'}).text } )