当前位置: 首页>>代码示例>>Python>>正文


Python feed.FeedGenerator类代码示例

本文整理汇总了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']
开发者ID:lkiesow,项目名称:python-feedgen,代码行数:31,代码来源:test_extension.py

示例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()
开发者ID:moridius,项目名称:feeder,代码行数:31,代码来源:feeder.py

示例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
开发者ID:rgegriff,项目名称:podiddly,代码行数:31,代码来源:models.py

示例4: run

def run(feeds):

    fgen = FeedGenerator()
    fgen.load_extension('podcast')


    result = reduce(merge, map(feed_parse, feeds), FeedGenerator())
    result.rss_file(sys.stdout)
开发者ID:histrio,项目名称:rssutils,代码行数:8,代码来源:rssmerge.py

示例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")
开发者ID:ryotarai,项目名称:github_trends_rss,代码行数:34,代码来源:main.py

示例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)
开发者ID:calpaterson,项目名称:dircast,代码行数:11,代码来源:feed.py

示例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))
开发者ID:glogiotatidis,项目名称:rockfeeder,代码行数:12,代码来源:feed.py

示例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
开发者ID:mimir-d,项目名称:small_projects,代码行数:9,代码来源:sample.py

示例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
开发者ID:hackcyprus,项目名称:jobber,代码行数:10,代码来源:rss.py

示例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
开发者ID:mimir-d,项目名称:small_projects,代码行数:10,代码来源:youtube.py

示例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')
开发者ID:lkiesow,项目名称:python-feedgen,代码行数:7,代码来源:test_extension.py

示例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
开发者ID:mimir-d,项目名称:small_projects,代码行数:15,代码来源:thecodinglove.py

示例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
开发者ID:cadrian,项目名称:pyceed,代码行数:43,代码来源:serve_feeds.py

示例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
开发者ID:snipem,项目名称:web-to-feed,代码行数:43,代码来源:webtofeed.py

示例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
开发者ID:lkiesow,项目名称:python-feedgen,代码行数:16,代码来源:test_entry.py


注:本文中的feedgen.feed.FeedGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。