本文整理汇总了Python中elementtree.ElementTree.SubElement.attrib["domain"]方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.attrib["domain"]方法的具体用法?Python SubElement.attrib["domain"]怎么用?Python SubElement.attrib["domain"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.attrib["domain"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetFeedElement
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import attrib["domain"] [as 别名]
def GetFeedElement(feed):
"""Create an atom:feed element for the provided feed.
The provided feed must be in the format described at http://feedparser.org.
"""
rss = Element("rss")
rss.attrib["version"] = "2.0"
root = SubElement(rss, "channel")
TextElement(root, "title", feed.feed.get("title_detail"))
if feed.feed.has_key("links"):
for link in feed.feed.links:
if link.rel != "self": continue
SubElementIf(root, "link", link.href)
TextElement(root, "description", feed.feed.get("subtitle_detail"))
TextElement(root, "copyright", feed.feed.get("rights_detail"))
SubElement(root, "generator").text = "feedarchive"
if feed.feed.has_key("image"):
im = feed.feed.image
ie = SubElement(root, "image")
SubElementIf(ie, "url", im.get("href"))
SubElementIf(ie, "title", im.get("title"))
SubElementIf(ie, "link", im.get("link"))
if feed.feed.has_key("tags"):
for tag in feed.feed.tags:
te = SubElement(root, "category")
if (tag.has_key("scheme")): te.attrib["domain"] = tag.scheme
te.text = tag.term
for entry in feed.entries:
ee = SubElement(root, "item")
TextElement(ee, "title", entry.get("title_detail"))
SubElementIf(ee, "link", entry.get("link"))
TextElement(ee, "description", entry.get("summary_detail"))
SubElementIf(ee, "guid", entry.get("id"))
DateTimeElement(ee, "pubDate", entry, "published")
PersonElement(ee, "author", entry.get("author_detail"))
if entry.has_key("links"):
for link in entry.links:
if link.rel != "enclosure": continue
ence = SubElement(ee, "enclosure")
AttribIf(ence, "url", link.get("url"))
AttribIf(ence, "length", link.get("length"))
AttribIf(ence, "type", link.get("type"))
return rss