def get_latest_data(self): # Get the users most recent diggs self.base_url = 'http://services.digg.com/1.0/endpoint?method=user.getDiggs&username=%s&count=%s' self.url = self.base_url % (self.username, self.count) self.xml = utils.getxml(self.url) # Parse out the story_id and datetime self.diggs = [(i.get('story'), i.get('date')) for i in self.xml.getchildren()] # A list of we'll ultimately pass out self.link_list = [] # Now loop through the diggs for story, date in self.diggs: # And pull information about the stories story_url = 'http://services.digg.com/2.0/story.getInfo?story_ids=%s' % str(story) story_json = utils.getjson(story_url) story_obj = story_json['stories'][0] # A dict to stuff all the good stuff in story_dict = { # Since the digg_date is expressed in epoch seconds, # we can start like so... 'date': utils.parsedate(time.ctime(float(date))), } # Get the link story_dict['url'] = smart_unicode(story_obj.get('url')) # Get the title story_dict['title'] = smart_unicode(story_obj.get('title')) story_dict['description'] = smart_unicode(story_obj.get('description')) # Get the topic story_dict['topic'] = smart_unicode(story_obj.get("topic").get('name')) # Pass the dict out to our list self.link_list.append(story_dict) return self.link_list
def __call__(self, **params): params['method'] = self.method params['api_key'] = self.api_key params['format'] = 'json' params['nojsoncallback'] = '1' url = "http://flickr.com/services/rest/?" + urllib.urlencode(params) json = utils.getjson(url) if json.get("stat", "") == "fail": raise FlickrError(json["code"], json["message"]) return json
def get_latest_data(self): self.location_list = [] self.json = utils.getjson(self.url) self.beer_list = [] for b in self.json['response']['checkins']['items']: d = dict( title=b['beer']['beer_name'], brewery=b['brewery']['brewery_name'], pub_date=utils.parsedate(b['created_at']), url='https://untappd.com/user/palewire/checkin/%s' % b['checkin_id'], ) self.beer_list.append(d) return self.beer_list
def get_latest_data(self): self.location_list = [] self.json = utils.getjson(self.url) self.beer_list = [] for b in self.json['results']: d = dict( title=b['beer_name'], brewery=b['brewery_name'], pub_date=utils.parsedate(b['created_at']), url=b['checkin_link'], ) self.beer_list.append(d) return self.beer_list
def fetch(self, cat): params = dict( count=100, cat=cat, ) data = utils.getjson(self.URL % params) headline_list = [ dict( title=i['title'].replace("(%s)" % i['source'], "").strip(), link=i['url'], description=i['summary'], pub_date=utils.parsedate(i['publish_date']), source=i['source'], ) for i in data['articles'] ] headline_list = [i for i in headline_list if len(i['title']) > 1] return [i for i in headline_list if i['title'][-1] == '?']
def get_latest_data(self): self.json = [d for d in utils.getjson(self.feed_url) if d['type'] == 'PushEvent'] for entry in self.json: for commit in entry['payload']['commits']: # Create a dict to stuff the goodies entry_dict = { 'pub_date': dateutil.parser.parse(entry['created_at']), 'branch': entry['payload']['ref'].split("/")[-1], 'repository': entry['repo']['name'], 'message': commit['message'], 'url': commit['url'], } # Add the dict to the entry list self.commit_list.append(entry_dict) # Pass out the commit_list return self.commit_list