本文整理汇总了Python中feedgen.feed.FeedGenerator类的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator类的具体用法?Python FeedGenerator怎么用?Python FeedGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FeedGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestExtensionTorrent
class TestExtensionTorrent(unittest.TestCase):
def setUp(self):
self.fg = FeedGenerator()
self.fg.load_extension('torrent')
self.fg.title('title')
self.fg.link(href='http://example.com', rel='self')
self.fg.description('description')
def test_podcastEntryItems(self):
fe = self.fg.add_item()
fe.title('y')
fe.torrent.filename('file.xy')
fe.torrent.infohash('123')
fe.torrent.contentlength('23')
fe.torrent.seeds('1')
fe.torrent.peers('2')
fe.torrent.verified('1')
assert fe.torrent.filename() == 'file.xy'
assert fe.torrent.infohash() == '123'
assert fe.torrent.contentlength() == '23'
assert fe.torrent.seeds() == '1'
assert fe.torrent.peers() == '2'
assert fe.torrent.verified() == '1'
# Check that we have the item in the resulting XML
ns = {'torrent': 'http://xmlns.ezrss.it/0.1/dtd/'}
root = etree.fromstring(self.fg.rss_str())
filename = root.xpath('/rss/channel/item/torrent:filename/text()',
namespaces=ns)
assert filename == ['file.xy']
示例2: Feeder
class Feeder():
def __init__( self, url, title='', feedURL='' ):
scraper = None
if url.startswith( "https://twitter.com/" ):
scraper = TwitterScraper( url )
if title == '':
title = "Twitter: @" + url.split('/')[3]
elif url.startswith( "http://www.lindwurm-linden.de/termine" ):
scraper = LindwurmScraper( url )
if title == '':
title = "Lindwurm: Termine"
else:
raise UnsupportedService( "No scraper found for this URL." )
self.feed = FeedGenerator()
self.feed.id( url )
self.feed.title( title )
self.feed.author( { "name": url } )
if feedURL != '':
self.feed.link( href=feedURL, rel='self' )
for entry in scraper.entries:
fe = self.feed.add_entry()
fe.id( entry['url'] )
fe.title( entry['title'] )
fe.link( href=entry['url'], rel='alternate' )
fe.content( entry['text'] )
def GetAtom( self ):
return self.feed.atom_str( pretty=True ).decode()
示例3: generate_feed
def generate_feed(self):
fg = FeedGenerator()
fg.load_extension('podcast')
for field in self.MAPPINGS:
value_names = field[0]
methods = field[1]
values = []
# collect the values from self
for value_name in value_names:
values.append( getattr(self, value_name) )
# decend the attribute tree
method = get_method(methods, fg)
# apply the values to the found method
method(*values)
for episode in self.episodes.all():
# This is the same pattern as above, I wonder if I can DRY this out.
entry = fg.add_entry()
value_names, method_names = zip(*episode.MAPPINGS)
values = []
for ind, value_name in enumerate(value_names):
print value_name
values = [getattr(episode, v) for v in value_name]
if None not in values:
print values
method = get_method(method_names[ind], entry)
method(*values)
print "DONE"
return fg
示例4: run
def run(feeds):
fgen = FeedGenerator()
fgen.load_extension('podcast')
result = reduce(merge, map(feed_parse, feeds), FeedGenerator())
result.rss_file(sys.stdout)
示例5: generate_rss
def generate_rss(language, since):
url = "{0}?since={1}".format(language["url"], since)
file_name = "github_trends_{0}_{1}.rss".format(language["key"], since)
title = "GitHub Trends - {0} - {1}".format(language["name"], since.capitalize())
print(url)
page = requests.get(url)
tree = html.fromstring(page.content)
lis = tree.cssselect("ol.repo-list li")
fg = FeedGenerator()
fg.title(title)
fg.link(href="http://github-trends.ryotarai.info/rss/{0}".format(file_name))
fg.description(title)
index = 1
for li in lis:
a = li.cssselect("h3 a")[0]
description = ""
ps = li.cssselect("p")
if len(ps) > 0:
description = ps[0].text_content().strip()
fe = fg.add_entry()
fe.link(href="https://github.com{0}".format(a.get("href")))
fe.title("{0} (#{1} - {2} - {3})".format(
a.text_content().strip().replace(" / ", "/"),
index,
language["name"],
since.capitalize(),
))
fe.description(description)
index += 1
rssfeed = fg.rss_str(pretty=True)
s3.Object(bucket, 'rss/{0}'.format(file_name)).put(Body=rssfeed, ContentType="application/xml")
示例6: generate_feed
def generate_feed(channel_dict, file_metadatas):
fg = FeedGenerator()
fg.load_extension("podcast")
fg.link(href=channel_dict["url"], rel="self")
fg.title(channel_dict["title"])
fg.description(channel_dict["description"])
for file_metadata in file_metadatas:
add_entry(fg, file_metadata)
return fg.rss_str(pretty=True)
示例7: generate_feed
def generate_feed(location, events):
fg = FeedGenerator()
fg.title('Upcoming Concerts in {}'.format(location.capitalize()))
fg.link(href='http://example.com', rel='alternate' )
fg.description('Upcoming rockin\' concerts')
for event in events.values():
fe = fg.add_entry()
fe.id(event['link'])
fe.title(event['groups'])
fe.description(u'{} / {} / {}'.format(event['date'], event['city_venue'], event['price']))
fe.link(href=event['link'])
fg.rss_file('html/feeds/{}.rss'.format(location))
示例8: _get_header
def _get_header(self):
rss = FeedGenerator()
rss.load_extension('dc')
rss.title('Feed title: %s' % self._rss_path)
rss.link(href=self.__URL, rel='self')
rss.description('Feed description')
return rss
示例9: build_feed_generator
def build_feed_generator(query=None):
gen = FeedGenerator()
gen.title(FEED_TITLE)
gen.subtitle(FEED_SUBTITLE)
gen.language(FEED_LANG)
feed_link = url_for('views.feed', query=query, _external=True)
gen.link(href=feed_link, rel='self', type='application/rss+xml')
return gen
示例10: _get_header
def _get_header(self):
title, desc, self.__uploads_id = self.__get_channel_details(self._rss_path)
rss = FeedGenerator()
rss.load_extension('dc')
rss.title(title)
rss.link(href=self.__PLAYLIST_URL % self.__uploads_id, rel='self')
rss.description(desc or title)
return rss
示例11: setUp
def setUp(self):
self.fg = FeedGenerator()
self.fg.load_extension('media')
self.fg.id('id')
self.fg.title('title')
self.fg.link(href='http://example.com', rel='self')
self.fg.description('description')
示例12: _get_header
def _get_header(self):
rss = FeedGenerator()
rss.load_extension('dc')
# channel xml tags
chan_details = self.__get_xml_dict(
self.__rss_xml.find('channel'),
['title', 'description', 'link']
)
rss.title(chan_details['title'])
rss.link(href=chan_details['link'], rel='self')
rss.description(chan_details['description'])
return rss
示例13: serve_filter
def serve_filter(type, filtername):
try:
fil = trn.select_unique(Filter, name=filtername, insert=False)
except:
logging.exception("serve_filter failed for filter %s" % (filtername,))
raise
out_feed = FeedGenerator()
out_feed.title(fil.title)
out_feed.subtitle(fil.subtitle)
out_feed.id(filtername)
for entry in fil.entries():
d = entry.definition
out_entry = out_feed.add_entry()
out_entry.title(d.title)
out_entry.published(getattr(d, "published", None))
out_entry.updated(getattr(d, "updated", None))
out_entry.id(d.id)
out_entry.summary(d.summary)
for c in getattr(d, "content", []):
out_entry.content(content=c.value, type=c.type) #, src=c.base
for l in getattr(d, "links", []):
out_entry.link(link=l)
try:
if type == "atom":
mimetype = "application/atom+xml"
result = out_feed.atom_str()
else:
mimetype = "application/rss+xml"
result = out_feed.rss_str()
except:
logging.exception("%s error", type)
mimetype = "text/plain"
result = """
An error occurred while trying to produce this feed.
You could try using %s instead.
""" % ("rss" if type == "atom" else "atom",)
response.content_type = mimetype
return result
示例14: parseString
def parseString(html, url, tag):
parsed_html = BeautifulSoup(html)
parsedUrl = urlparse(url)
baseUrl = parsedUrl.scheme+"://"+parsedUrl.netloc
fg = FeedGenerator()
fg.id(url)
fg.title('Generated feed for ' + url)
fg.link( href=url, rel='alternate' )
fg.subtitle('Autogenerated by alltorss.py based on tag ' + tag)
for item in parsed_html.body.find_all(tag):
topic = item.text.strip()
#check if item contains a link
innerLink = findInnerLink(item)
outerLink = findOuterLink(item)
if (innerLink != None):
link = innerLink
elif (outerLink != None):
link = outerLink
else:
link = None
if isinstance(link, Tag) and link.has_attr('href'):
linkHref = link['href']
fe = fg.add_entry()
if (linkIsAbsolute(linkHref)):
fullLink = linkHref
else:
fullLink = baseUrl + linkHref
fe.id(fullLink)
fe.title(topic)
fe.link( href=fullLink )
return fg
示例15: test_categoryHasDomain
def test_categoryHasDomain(self):
fg = FeedGenerator()
fg.title('some title')
fg.link(href='http://www.dontcare.com', rel='alternate')
fg.description('description')
fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654321/1')
fe.title('some title')
fe.category([
{'term': 'category',
'scheme': 'http://www.somedomain.com/category',
'label': 'Category',
}])
result = fg.rss_str()
assert b'domain="http://www.somedomain.com/category"' in result