本文整理汇总了Python中models.Feed.title方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.title方法的具体用法?Python Feed.title怎么用?Python Feed.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.title方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_feed_github
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def add_feed_github(request, user=None):
# if user is None:
# return 'fail'
if request.user.is_authenticated():
user = request.REQUEST['user']
url = 'https://github.com/%s/' % user
feed_url = 'https://github.com/%s.atom' % user
# feed, create = Feed.objects.get_or_create(title=user)
category, created = Category.objects.get_or_create(name='github', slug='github')
feed = Feed()
feed.title = user
feed.url = url
feed.category = category
feed.feed_url = feed_url
feed.dt_checked = datetime.datetime(1, 1, 1, 0, 0, 0)
feed.dt_updated = datetime.datetime(1, 1, 1, 0, 0, 0)
feed.save()
return HttpResponse('yay')
# return HttpResponseRedirect('/admin/reader/feed/%d/' % (feed.id,))
else:
return 'h4axx0r..'
示例2: get_feed_from_url
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def get_feed_from_url(url):
"""
Download a rss 2.0 feed and returns a class which represents that feed.
:param url: URL of the feed to download.
:return: Feed
"""
rss = get_rss_feed_parser(url)
if not is_rss_feed_valid(rss):
raise LookupError("Sorry! We cannot parse the rss feed. Missing required element(s).")
feed = Feed()
feed.title = rss["channel"]["title"]
feed.link = rss["channel"]["link"]
feed.description = rss["channel"]["description"]
feed.image = FeedItemImage(
url=rss["channel"]["image"]["url"],
title=rss["channel"]["image"]["title"],
link=rss["channel"]["image"]["link"],
width=rss["channel"]["image"]["width"],
height=rss["channel"]["image"]["height"],
)
feed.items = []
for item in rss["items"]:
feed.items.append(
FeedItem(
title=item["title"],
link=item["link"],
guid=item["guid"],
pub_date=datetime.fromtimestamp(mktime(item["published_parsed"])),
)
)
return feed
示例3: post
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def post(self):
#表单字段: url, author, title, content, allow_sendto_kindle
f = Feed()
f.url = self.request.get('tUrl')
f.title = self.request.get('tTitle')
f.put(); # save
return self.redirect('/feed')
示例4: add_rss
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def add_rss(request, url=None):
if url is None:
url = request.REQUEST['url']
d = feedparser.parse(url)
feed = Feed()
feed.title = d.feed.get('title', 'Untitled')
feed.url = d.feed.get('link', url[:url.find('/', 8)])
feed.feed_url = url
feed.dt_checked = datetime.datetime(1, 1, 1, 0, 0, 0)
feed.dt_updated = datetime.datetime(1, 1, 1, 0, 0, 0)
feed.save()
update(request, feed.id)
return HttpResponseRedirect('/admin/reader/feed/%d/' % (feed.id,))
示例5: add_feed
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def add_feed():
title = request.form.get('title')
url = request.form.get('url')
delay = request.form.get('delay')
feed = Feed()
feed.url = url
feed.title = title
feed.delay = delay
feed.latest_fetch = datetime.datetime.now()
feed.put()
flash(u'KeyWord add successfully~', 'success')
flush_feed_cache()
return redirect(url_for("admin"))
示例6: init_gae
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import title [as 别名]
def init_gae():
f = Feed()
f.url = 'http://money.163.com/special/00252EQ2/yaowenrss.xml'
f.title = '要闻综合-网易财经'
f.put()