def PullNews(self): Configuration = ConfigurationReader() self.__APIKey = Configuration.GetAPIKEY() self.__Limit = Configuration.GetLimit() url = 'https://newsapi.org/v1/articles?source=' + self.Source + '&sortBy=top&apiKey=' + self.__APIKey try: req = requests.get(url) if (req.status_code == 200): return req else: print "There is some issue in connecting to the internet. Please check your firewall or internet" except ConnectionError as e: print "A connection Attempt failed" print e.message sys.exit()
def __init__(self,source,articleurl): self.extractorlist=[HuffingtonPost(),NYT(),BBC(),BloomBerg(),Guardian(),TheHindu(),TimesOfIndia()] websites=ConfigurationReader().GetWebsiteSupported() self.Mapping={} for index,website in enumerate(websites): self.Mapping[website]=self.extractorlist[index] self.Source=source self.url=articleurl self.textWrap=textwrap.TextWrapper(initial_indent='\t',subsequent_indent='\t',width=100)
def NewsSources(): NewsSources = ConfigurationReader().GetWebsiteSupported() return NewsSources
def __init__(self, newsSource): self.Source = newsSource Configuration = ConfigurationReader() self.__APIKey = Configuration.GetAPIKEY() self.__Limit = Configuration.GetLimit()
def NewsTopics(): NewsTopics = ConfigurationReader().GetTopicsSupported() return NewsTopics