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


Python Entry.link方法代码示例

本文整理汇总了Python中models.Entry.link方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.link方法的具体用法?Python Entry.link怎么用?Python Entry.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Entry的用法示例。


在下文中一共展示了Entry.link方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pull_feeds

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import link [as 别名]
def pull_feeds(request):
	sources = Source.objects.filter(usersource__user=request.user)

	for source in sources:
		if source.xml_url:
			d = feedparser.parse(source.xml_url)

			#update source with attributes from feed
			if 'icon' in d.feed:
				source.icon_url = d.feed.icon
			if 'updated_parsed' in d.feed and d.feed.updated_parsed is not None:
				source.updated_parsed = datetime.fromtimestamp(mktime(d.feed.updated_parsed))
			source.save()

			#print [field for field in d]
			for e in d['entries']:
				if 'published_parsed' in e:
					entry_published_date = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp
					if source.updated_parsed is None or entry_published_date>source.updated_parsed:
						entry = Entry(source=source, title=e.title, raw=e)
						if 'author_detail' in e:
							if 'name' in e.author_detail:
								entry.author_name = e.author_detail.name	
							if 'href' in e.author_detail:
								entry.author_href = e.author_detail.href
							if 'email' in e.author_detail:
								entry.author_email = e.author_detail.email
						if 'comments' in e:
							entry.comments_href = e.comments
						if 'content' in e:
							entry.content = e.content
						if 'contributors' in e:
							entry.contributors = e.contributors
						if 'link' in e:
							entry.link = e.link
						if 'links' in e:
							entry.links = e.links
						if 'created_parsed' in e:
							entry.created_parsed = datetime.fromtimestamp(mktime(e.created_parsed)) #feed timestamp
						if 'expired_parsed' in e:
							entry.expired_parsed = datetime.fromtimestamp(mktime(e.expired_parsed)) #feed timestamp
						if 'published_parsed' in e:
							entry.published_parsed = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp
						if 'updated_parsed' in e:
							entry.updated_parsed = datetime.fromtimestamp(mktime(e.updated_parsed)) #feed timestamp

						if 'summary' in e:
							entry.summary = e.summary
						entry.save()
				else:
					print 'Entry with no Publication date: %s' % e

	return HttpResponseRedirect( reverse('entries') )
开发者ID:juliangay,项目名称:ticker-tape,代码行数:55,代码来源:views.py


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