本文整理汇总了Python中feedgen.feed.FeedGenerator.webMaster方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.webMaster方法的具体用法?Python FeedGenerator.webMaster怎么用?Python FeedGenerator.webMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.webMaster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import webMaster [as 别名]
def main():
session = vk.Session()
api = vk.API(session)
group_id = '96469126'
group_info = api.groups.getById(group_ids=group_id, fields=['description', 'site', 'name', 'photo', 'gid'])
assert len(group_info) == 1
group_info = group_info[0]
url = 'http://vk.com/club{}'.format(group_info['gid'])
# a = api.wall.get(owner_id=-1 * group_info['gid'])
#
# with open('out', 'wb') as fio:
# pickle.dump(a, fio)
with open('out', 'rb') as fio:
data = pickle.loads(fio.read())
assert len(data) > 1
fg = FeedGenerator()
fg.id(url)
fg.title(_(group_info['name']))
fg.description(_(group_info['description']))
fg.logo(group_info['photo'])
site_url = group_info.get('site', url) if group_info.get('site', url) else url
fg.link(href=_(site_url))
fg.link(href=_(site_url), rel='self')
fg.link(href=_(site_url), rel='alternate')
fg.author({'name': 'Alexander Sapronov', 'email': '[email protected]'})
fg.webMaster('[email protected] (Alexander Sapronov)')
pat = re.compile(r"#(\w+)")
for x in data[1:]:
post_link = "{}?w=wall-{}_{}".format(url, group_info['gid'], x['id'])
e = fg.add_entry()
# text = x.get('text', '').replace('<br>', '\n')
text = x.get('text', '')
e.description(_(text))
e.author({'name': _(get_author_name(api, x.get('from_id')))})
e.id(post_link)
e.link(href=_(post_link))
e.link(href=_(post_link), rel='alternate')
tags = pat.findall(text)
title = x.get('text', '')
for tag in tags:
e.category(term=_(tag))
title = title.replace('#{}'.format(tag), '')
title = re.sub('<[^<]+?>', ' ', title)
title = textwrap.wrap(title, width=80)[0]
e.title(_(title.strip()))
fg.rss_file('rss.xml')
示例2: generate_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import webMaster [as 别名]
def generate_feed(input_file, output_file):
fg = FeedGenerator()
fg.load_extension('podcast', rss=True)
## RSS tags
# Required
fg.title(TITLE)
fg.link(href=LINK)
fg.description(DESCRIPTION)
# Optional
fg.language('en')
fg.image(url=IMAGE_URL, title=TITLE, link=LINK)
fg.ttl(720)
fg.webMaster(CONTACT['name'])
now = datetime.datetime.now()
tz = pytz.timezone('Europe/Amsterdam')
fg.pubDate(tz.localize(now))
# iTunes
fg.podcast.itunes_author('Dan LeBatard')
fg.podcast.itunes_category(itunes_category='Sports & Recreation', itunes_subcategory='Professional')
fg.podcast.itunes_image(itunes_image=IMAGE_URL)
fg.podcast.itunes_explicit(itunes_explicit='clean')
fg.podcast.itunes_owner(name=CONTACT['name'], email=CONTACT['email'])
# Add items
items = read_items(input_file)
for item in items:
fe = fg.add_entry()
## RSS tags
fe.id(item['guid'])
fe.title(item['title'])
fe.description(item['description'])
fe.enclosure(item['link'], 0, 'audio/mpeg')
fe.pubdate(item['pubDate'])
# Finish off the file
fg.rss_str(pretty=True)
fg.rss_file(output_file)
示例3: setUp
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import webMaster [as 别名]
def setUp(self):
fg = FeedGenerator()
self.nsAtom = "http://www.w3.org/2005/Atom"
self.nsRss = "http://purl.org/rss/1.0/modules/content/"
self.feedId = 'http://lernfunk.de/media/654321'
self.title = 'Some Testfeed'
self.authorName = 'John Doe'
self.authorMail = '[email protected]'
self.author = {'name': self.authorName, 'email': self.authorMail}
self.linkHref = 'http://example.com'
self.linkRel = 'alternate'
self.logo = 'http://ex.com/logo.jpg'
self.subtitle = 'This is a cool feed!'
self.link2Href = 'http://larskiesow.de/test.atom'
self.link2Rel = 'self'
self.language = 'en'
self.categoryTerm = 'This category term'
self.categoryScheme = 'This category scheme'
self.categoryLabel = 'This category label'
self.cloudDomain = 'example.com'
self.cloudPort = '4711'
self.cloudPath = '/ws/example'
self.cloudRegisterProcedure = 'registerProcedure'
self.cloudProtocol = 'SOAP 1.1'
self.icon = "http://example.com/icon.png"
self.contributor = {'name': "Contributor Name",
'uri': "Contributor Uri",
'email': 'Contributor email'}
self.copyright = "The copyright notice"
self.docs = 'http://www.rssboard.org/rss-specification'
self.managingEditor = '[email protected]'
self.rating = '(PICS-1.1 "http://www.classify.org/safesurf/" ' + \
'1 r (SS~~000 1))'
self.skipDays = 'Tuesday'
self.skipHours = 23
self.textInputTitle = "Text input title"
self.textInputDescription = "Text input description"
self.textInputName = "Text input name"
self.textInputLink = "Text input link"
self.ttl = 900
self.webMaster = '[email protected]'
fg.id(self.feedId)
fg.title(self.title)
fg.author(self.author)
fg.link(href=self.linkHref, rel=self.linkRel)
fg.logo(self.logo)
fg.subtitle(self.subtitle)
fg.link(href=self.link2Href, rel=self.link2Rel)
fg.language(self.language)
fg.cloud(domain=self.cloudDomain, port=self.cloudPort,
path=self.cloudPath,
registerProcedure=self.cloudRegisterProcedure,
protocol=self.cloudProtocol)
fg.icon(self.icon)
fg.category(term=self.categoryTerm, scheme=self.categoryScheme,
label=self.categoryLabel)
fg.contributor(self.contributor)
fg.copyright(self.copyright)
fg.docs(docs=self.docs)
fg.managingEditor(self.managingEditor)
fg.rating(self.rating)
fg.skipDays(self.skipDays)
fg.skipHours(self.skipHours)
fg.textInput(title=self.textInputTitle,
description=self.textInputDescription,
name=self.textInputName, link=self.textInputLink)
fg.ttl(self.ttl)
fg.webMaster(self.webMaster)
fg.updated('2017-02-05 13:26:58+01:00')
fg.pubDate('2017-02-05 13:26:58+01:00')
fg.generator('python-feedgen', 'x', uri='http://github.com/lkie...')
fg.image(url=self.logo,
title=self.title,
link=self.link2Href,
width='123',
height='123',
description='Example Inage')
self.fg = fg