Created
October 12, 2020 04:34
-
-
Save esenthil2018/49aad3d32b134ab2b1d42f426d79dc10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import feedparser | |
import pandas as pd | |
class WhizRssAggregator(): | |
feedurl = "" | |
#global df | |
#df = pd.DataFrame(columns=['title', 'link', 'decription','published', 'content']) | |
def __init__(self, paramrssurl): | |
print(paramrssurl) | |
self.feedurl = paramrssurl | |
self.parse() | |
def parse(self): | |
thefeed = feedparser.parse(self.feedurl) | |
global df | |
df = pd.DataFrame(columns=['title', 'link', 'decription','published', 'content']) | |
#print("Getting Feed Data") | |
#print(thefeed.feed.get("title", "")) | |
#print(thefeed.feed.get("link", "")) | |
#print(thefeed.feed.get("description", "")) | |
#print(thefeed.feed.get("published", "")) | |
published = thefeed.feed.get("description", "") | |
#print(thefeed.feed.get("published_parsed", | |
#thefeed.feed.published_parsed)) | |
for thefeedentry in thefeed.entries: | |
#print("__________") | |
#print(thefeedentry.get("guid", "")) | |
#print(thefeedentry.get("title", "")) | |
title = thefeedentry.get("title", "") | |
#print(thefeedentry.get("link", "")) | |
link = thefeedentry.get("link", "") | |
#print(thefeedentry.get("description", "")) | |
decr = thefeedentry.get("description", "") | |
#print("__________") | |
df = df.append({'title': title, 'link': link, 'decription': decr,'published': published}, ignore_index=True) | |
#dfObj = dfObj.append({'User_ID': 23, 'UserName': 'Riti', 'Action': 'Login'}, ignore_index=True) | |
return df | |
#from whizrssaggregator import WhizRssAggregator | |
#df = pd.DataFrame(columns=['title', 'link', 'decription','published']) | |
url_link = "https://rss.nytimes.com/services/xml/rss/nyt/US.xml" | |
rssobject=WhizRssAggregator(url_link) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment