Exemplo n.º 1
0
        print "Polling . . .",

        # Get stories from Google's Top Stories RSS news feed
        stories = process("http://news.google.com/?output=rss")
        # Get stories from Yahoo's Top Stories RSS news feed
        stories.extend(process("http://rss.news.yahoo.com/rss/topstories"))

        # Only select stories we're interested in
        stories = filter_stories(stories, triggerlist)
    
        # Don't print a story if we have already printed it before
        newstories = []
        for story in stories:
            print ". . .",
            if story.get_guid() not in guidShown:
                newstories.append(story)
        print ". . ."
        for story in newstories:
            guidShown.append(story.get_guid())
            p.newWindow(story)

        print "Sleeping..."
        time.sleep(SLEEPTIME)

SLEEPTIME = 60 #seconds -- how often we poll
if __name__ == '__main__':
    p = Popup()
    thread.start_new_thread(main_thread, (p,))
    p.start()

Exemplo n.º 2
0
    while True:
        print "Polling..."

        # Get stories from Google's Top Stories RSS news feed
        stories = process("http://news.google.com/?output=rss")
        # Get stories from Yahoo's Top Stories RSS news feed
        stories.extend(process("http://rss.news.yahoo.com/rss/topstories"))

        # Only select stories we're interested in
        stories = filter_stories(stories, triggerlist)

        # Don't print a story if we have already printed it before
        newstories = []
        for story in stories:
            if story.get_guid() not in guidShown:
                newstories.append(story)

        for story in newstories:
            guidShown.append(story.get_guid())
            p.newWindow(story)

        print "Sleeping..."
        time.sleep(SLEEPTIME)


SLEEPTIME = 60  #seconds -- how often we poll
if __name__ == '__main__':
    p = Popup()
    thread.start_new_thread(main_thread, (p, ))
    p.start()
Exemplo n.º 3
0
        # Let's do some sentiment analysis
        sia = SIA()

        for story in stories:
            # generate the news_score: 'compound', 'headline', 'neg', 'neu', 'pos'
            pol_score = sia.polarity_scores(story.get_summary())
            pol_score['headline'] = story.get_title()
            story.set_score(pol_score)
            if (story.get_guid() not in guidShown) & (pol_score['compound'] > 0.5)\
                & (pol_score['pos'] > 0.1) & (pol_score['neg'] < 0.07) :
                newstories.append(story)

        for story in newstories:
            guidShown.append(story.get_guid())
            print(
                f'***************{story.get_title()}**{story.score}****************'
            )
            print(story.get_summary())
            popup.newWindow(story)

        print("Sleeping...")
        time.sleep(SLEEPTIME)


SLEEPTIME = 300  #seconds -- how often we poll
if __name__ == '__main__':
    popup = Popup()
    thread.start_new_thread(main_thread, (popup, ))
    popup.start()