-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main.py
61 lines (50 loc) · 2.26 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# coding: utf-8
import params
import pandas as pd
from Scrapper.GoogleScrapper import GoogleScrapper
from Scrapper.BlogScrapper import BlogScrapper
from Scrapper.YoutubeScrapper import YoutubeScrapper
from SentimentAnalysis import SentimentAnalysis
import os
def main():
DataPath ='{}/Data'.format(params.homepath)
youtubeapi = params.youtubeapi
youtubecommentapi = params.youtubecommentapi
kpram = params.youtubeparams
vparams = params.params_v
Sentiment = SentimentAnalysis()
youtube=YoutubeScrapper()
comments , video_id = youtube.youtubescrapper(youtubeapi,kpram,youtubecommentapi,vparams)
sent, sentVal = Sentiment.txtanalysis(comments)
d = {'comments':comments,'video_id':video_id,'label':sent,'sentVal':sentVal}
df = pd.DataFrame(d) #creates empty dataframe
filename = os.path.join(DataPath, params.youtubefilename).replace("\\","/")
df.to_csv(filename)
print('Youtube Average Sentiment:',Sentiment.avgsentiment(comments))
url = params.newsurl #'https://news.google.com/?output=rss&q='
symbol = params.newssymbol
Google = GoogleScrapper()
links, titles = Google.Google_Scrap(url,symbol)
news = Google.Google_newsStoryGrabber(links)
#seenews = Google_seeNews(titles,links)
#print(seenews)
sent, sentVal = Sentiment.txtanalysis(news)
d = {'links':links, 'news':news,'titles':titles,'label':sent,'sentVal':sentVal}
df = pd.DataFrame(d) #creates empty dataframe
filename = os.path.join(DataPath, params.newsfilename).replace("\\","/")
df.to_csv(filename)
print('Google News Average Sentiment:' , Sentiment.avgsentiment(news))
blogurl = params.blogurl #"https://www.narendramodi.in/blog/loadblogs?language=en&page="
Blog =BlogScrapper()
links, titles = Blog.blog_parser(blogurl)
text = Blog.blog_newsStoryGrabber(links)
#seenews = BlogScrapper.blog_seeNews(links)
#print(seenews)
sent, sentVal = Sentiment.txtanalysis(text)
d = {'links':links, 'text':text,'titles':titles,'label':sent,'sentVal':sentVal}
df = pd.DataFrame(d) #creates empty dataframe
filename = os.path.join(DataPath, params.blogfilename).replace("\\","/")
df.to_csv(filename)
print('Blogs Average Sentiment:', Sentiment.avgsentiment(text))
if __name__=='__main__':
main()