本文整理汇总了Python中feed.Feed类的典型用法代码示例。如果您正苦于以下问题:Python Feed类的具体用法?Python Feed怎么用?Python Feed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Feed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_headlines
def load_headlines():
global headlines_url
global response_headline
global headlines_data
global stories
headlines_url = "http://sanfrancisco.giants.mlb.com/gen/sf/news/headlines.json"
feed = Feed(headlines_url)
feed.load_and_prepare()
succeeded, loaded_headlines_json = feed.get_representation
length = len(loaded_headlines_json["members"])
story_elements = []
story_blurbs = []
story_url = []
for index in range(length):
story_elements.append(loaded_headlines_json["members"][index])
length = len(story_elements)
stories = []
for index in range(length):
try:
item = NewsItem(story_elements[index]["althead"], story_elements[index]["url"])
stories.append(item)
except:
print "No althead or url found at index %d; skipping to next item..." % index
continue
示例2: checkFeed
def checkFeed(args):
if len(args) != 1:
print 'No feed given. Please specify a link to an RSS feed to re-classify.'
return
print 'Existing feed data:'
feedStatus(args)
feed = Feed(url=args[0])
print 'Working with: %s' % feed.url
print 'Attempting to download the feed.'
couldDownload = feed.downloadFeed()
if not couldDownload:
print 'Could not download the feed. Is the URL correct? Is their site up? Is GTWifi working for you right now?'
return
print 'Successfully downloaded the feed.'
print 'Attempting to parse the feed.'
parseError, stats = feed.parseFeed()
if parseError is None:
print 'Successfully parsed the feed.'
print stats
if len(feed.articles) == 0:
print 'No articles parsed. Something is wrong'
示例3: country_articles
def country_articles(country=None):
from feed import Feed
country=country.encode('ascii', 'ignore')
country=country.replace("Dem.", "Democratic")
country=country.replace("Rep.", "Republic")
country=country.replace("W.", "West")
country=country.replace("Lao PDR", "Laos")
country=country.replace("Bosnia and Herz.", "Bosnia and Herzegovina")
country=country.replace("Eq. Guinea", "Equatorial Guinea")
country=country.replace("Cte d'Ivoire", "Ivory Coast")
country=country.replace("Fr. S. Antarctic Lands", "French Southern and Antarctic Lands")
country=country.replace("Is.", "Islands")
country=country.replace("S. Sudan", "South Sudan")
country=country.replace(" ", "_")
print country
url1="http://api.feedzilla.com/v1/categories/19/articles/search.atom?q="+country+"&count=50"
feed = Feed(url1)
# url2="http://api.feedzilla.com/v1/categories/26/articles/search.atom?q="+country+"&count=10"
# feed.add_feed(url2)
# feed = Feed()
# feed.load()
# feed.filter_country(country)
feed.extract()
return feed.to_json()
示例4: articles
def articles():
from feed import Feed
# feed = Feed('data/2014-04-05_16-54.atom')
feed = Feed()
feed.load()
return feed.to_json()
示例5: load
def load(self, store):
for group in store.childGroups():
store.beginGroup(group)
feed = Feed()
feed.load(store)
self.feeds.append(feed)
store.endGroup()
示例6: __init__
def __init__(self,cache_dir,status_change_handler):
Feed.__init__(self)
print "init local feed"
self.handler = LocalHandler()
self.cache_dir = cache_dir
self.filename = os.path.join(self.cache_dir, "local.xml")
self.uri = "http://www.programmierecke.net/programmed/local.xml"
self.status_change_handler = status_change_handler
示例7: POST
def POST(self):
feed = Feed()
if feed.add(web.input(url="url")["url"]):
raise web.seeother("/")
else:
user_id = session.user_id
error_message = "Invalid feed url"
render.feed_add(error_message, user_id)
示例8: __init__
def __init__(self,cache_dir,status_change_handler):
Feed.__init__(self)
print "init board feed"
self.handler = BoardHandler()
self.cache_dir = cache_dir
self.filename = os.path.join(self.cache_dir, "board.xml")
self.uri = "http://www.radio-browser.info/xml.php"
self.status_change_handler = status_change_handler
示例9: __init__
def __init__(self, cache_dir, status_change_handler):
Feed.__init__(self)
print "init icecast feed"
self.handler = IcecastHandler()
self.cache_dir = cache_dir
self.filename = os.path.join(self.cache_dir, "icecast.xml")
self.uri = "http://dir.xiph.org/yp.xml"
self.status_change_handler = status_change_handler
示例10: __init__
def __init__(self,cache_dir,status_change_handler):
Feed.__init__(self)
print("init shoutcast feed")
self.handler = ShoutcastHandler()
self.cache_dir = cache_dir
self.filename = os.path.join(self.cache_dir, "shoutcast-genre.xml")
self.uri = "http://www.shoutcast.com/sbin/newxml.phtml"
self.status_change_handler = status_change_handler
示例11: get_scoreboard_info
def get_scoreboard_info():
global year
global month
global day
global giants_pitcher_name
global giants_pitcher_era
global end_game_message
global current_game_status
global current_game_inning
master_scoreboard_url = "http://mlb.mlb.com/gdcross/components/game/mlb/year_%s/month_%s/day_%s/master_scoreboard.json" % (year, str(month).zfill(2), str(day).zfill(2))
feed = Feed(master_scoreboard_url)
feed.load_and_prepare()
succeeded, loaded_schedule_json = feed.get_representation
schedule_list = loaded_schedule_json["data"]["games"]["game"]
send = client.sock.send
for game in schedule_list:
try:
if game["away_team_name"] == "Giants" or game["home_team_name"] == "Giants":
current_game_status = game["alerts"]["brief_text"]
# if "Middle 7th" in game["alerts"]["brief_text"]:
# msg = "PRIVMSG " + input[2] + " :" + "When the lights.. go down.. in the cityyy... https://www.youtube.com/watch?v=tNG62fULYgI" "\r\n"
# send(msg) # https://www.youtube.com/watch?v=tNG62fULYgI
except:
if "winning_pitcher" in game and (game["home_team_name"] == "Giants" or game["away_team_name"] == "Giants"):
winning_pitcher = "%s %s" % (game["winning_pitcher"]["first"], game["winning_pitcher"]["last"])
losing_pitcher = "%s %s" % (game["losing_pitcher"]["first"], game["losing_pitcher"]["last"])
end_game_message = "Game over. Winning pitcher: %s. Losing pitcher: %s." % (winning_pitcher, losing_pitcher)
current_game_status = ""
else:
current_game_status = "No active game."
if game["away_team_name"] == "Giants":
if "away_probable_pitcher" in game:
giants_pitcher_name = "%s %s" % (game["away_probable_pitcher"]["first"], game["away_probable_pitcher"]["last"])
giants_pitcher_era = game["away_probable_pitcher"]["era"]
return
elif "opposing_pitcher" in game:
giants_pitcher_name = "%s %s" % (game["opposing_pitcher"]["first"], game["opposing_pitcher"]["last"])
giants_pitcher_era = game["opposing_pitcher"]["era"]
return
elif game["home_team_name"] == "Giants":
if "home_probable_pitcher" in game:
giants_pitcher_name = "%s %s" % (game["home_probable_pitcher"]["first"], game["home_probable_pitcher"]["last"])
giants_pitcher_era = game["home_probable_pitcher"]["era"]
return
elif "pitcher" in game:
giants_pitcher_name = "%s %s" % (game["pitcher"]["first"], game["pitcher"]["last"])
giants_pitcher_era = game["pitcher"]["era"]
return
示例12: frontpage
def frontpage(request):
add_video_url = request.route_url('add_video')
user_id = request.authenticated_userid
user = DBHelper.get_user_from_id(user_id)
topics = DBHelper.get_all_topics()
topic_ids = [x.id for x in topics]
feed = Feed()
all_videos = feed.build_feed(user_id, topic_ids)
return {'videos': all_videos, 'logged_in': user, 'topics':topics}
示例13: create_feed
def create_feed(self, init_data):
""" Create a feed-object by given parameters. """
feed = Feed(init_data, feedhandler=self)
feed.connect('updated', self.sig_feed_updated)
feed.connect(
'created',
self._create_feed_deferred,
init_data["url"], init_data["feed_name"]
)
示例14: vote_video
def vote_video(request):
user_id = request.authenticated_userid
vote = request.matchdict['vote']
video_id = int(request.matchdict['video_id'])
topic_id = DBHelper.get_video(video_id).topic_id
change = DBHelper.vote_video(user_id, video_id, vote)
feed = Feed()
feed.update_video_score(video_id, topic_id, change)
return {'change': change}
示例15: _subscribe_to_feed
def _subscribe_to_feed(self, asset_id, subscriber_id, callback, sub_type=SUBTYPE_MID):
if asset_id in self._feeds:
f = self._feeds[asset_id]
else:
f = Feed(asset_id, 5)
self._feeds[asset_id] = f
if sub_type == SUBTYPE_MID:
f.subscribe_to_mid_updates(subscriber_id, callback)
elif sub_type == SUBTYPE_LAST:
f.subscribe_to_last_updates(subscriber_id, callback)