diff --git a/README.md b/README.md index d2616b3..af01d18 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ Program to prepare tree visualization of data in python giving output in pdf for ## 9. RockPaperScissorGame Program to let users play Rock Paper Scissor with computer. -## 10. Some other functions +## 10. Some Basic Programs + # How To RUN - Install python3. diff --git a/Some basic programs/ScoreCalculate.py b/Some basic programs/ScoreCalculate.py new file mode 100644 index 0000000..9d8b45a --- /dev/null +++ b/Some basic programs/ScoreCalculate.py @@ -0,0 +1,56 @@ +import feedparser +import requests +import re +from textblob import TextBlob +from bs4 import BeautifulSoup + +''' +Allow for argument to be sent, screen for a valid stock, return unique score. +''' + + +#Manually change the ticker to whatever stock acronym you want here +#GE is a terrible company in the news right now and gets a low score at around 6 +#AAPL great company score above 10 + +ticker = 'GE' + +site = "https://seekingalpha.com/api/sa/combined/.xml" + + +site = site[:41] + ticker + site[41:] +'''This creates the xml site''' + + +d = feedparser.parse(site) + +individualArticles = 'https://seekingalpha.com/symbol//news?source=feed_symbol_' +individualArticles = individualArticles[:32] + ticker + individualArticles[32:] +individualArticles = individualArticles[:61] + ticker + individualArticles[61:] +'''this adds the ticker to two more places to check for the generic site filter ''' + +#print (individualArticles) + +allarticles = '' +for entry in d.entries: + + if entry.link != individualArticles: + url = entry.link + response = requests.get(url); + soup = BeautifulSoup(response.content, 'html.parser') + line = '' + + for words in soup.findAll('p'): + line += words.text.strip() + + allarticles+=line + + +#Textblob is the SA library I use to analyze the articles +sarticles = TextBlob(allarticles) +score = sarticles.sentiment.polarity +score = score*100 + +print(score) + +