我正在寻找可以读取 MRSS(媒体 RSS)文件并向其添加新条目的包或函数。
我尝试使用xml.etree.ElementTree
以读取 MRSS 文件,但是当它读取文件并将其保存时,将media:<...>
元素更改为ns0:<...>
这是我试图读取的文件:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
<title>ReelSEO Video News</title>
<link>https://tubularinsights.com/examples/mrss/</link>
<description>The ReelSEO Video News Archive</description>
<item>
<title>MRRS Example Video</title>
<link>https://tubularinsights.com/examples/mrss/example.html</link>
<description>The example landing page for this MRSS item</description>
<guid isPermaLink="false">https://tubularinsights.com/examples/mrss/example.html</guid>
<media:content url="https://tubularinsights.com/examples/mrss /example.avi" fileSize="405321" type="video/x-msvideo" height="240" width="320" duration="120" medium="video" isDefault="true">
<media:title>The ReelSEO MRSS example video</media:title>
<media:description>Check out the 120 seconds of fast-paced MRSS fun with ReelSEO.</media:description>
<media:thumbnail url="https://tubularinsights.com/examples/mrss/example.png" height="120" width="160" />
</media:content>
</item>
</channel>
</rss>
这是在这样做之后:
tree = ET.parse('rss.xml')
root = tree.getroot()
tree.write("rss3.xml")
输出:
<rss xmlns:ns0="http://search.yahoo.com/mrss/" version="2.0">
<channel>
<title>ReelSEO Video News</title>
<link>https://tubularinsights.com/examples/mrss/</link>
<description>The ReelSEO Video News Archive</description>
<item>
<title>MRRS Example Video</title>
<link>https://tubularinsights.com/examples/mrss/example.html</link>
<description>The example landing page for this MRSS item</description>
<guid isPermaLink="false">https://tubularinsights.com/examples/mrss/example.html</guid>
<ns0:content duration="120" fileSize="405321" height="240" isDefault="true" medium="video" type="video/x-msvideo" url="https://tubularinsights.com/examples/mrss /example.avi" width="320">
<ns0:title>The ReelSEO MRSS example video</ns0:title>
<ns0:description>Check out the 120 seconds of fast-paced MRSS fun with ReelSEO.</ns0:description>
<ns0:thumbnail height="120" url="https://tubularinsights.com/examples/mrss/example.png" width="160" />
</ns0:content>
</item>
<item><guid isPermaLink="false">9030c790cf3911e893a29cb6d0d6506a</guid><title>Student Invents Phone Charger Powered by Spinning</title><description>Mikhail Vaga, a 19-year-old student from Minsk, invented the gyroscope powerbank which transforms human kinetic energy into electricity which can charge gadgets. Vaga set up a crowdfunding campaign on Kickstarter to receive backing for his innovative idea, and his project raised over $50,000 in two weeks. Top backers already received the powerbanks from the first production run for $79 apiece, and Vaga is now preparing for mass-production.</description><pubDate>Mon Oct 15 15:11:03 2018</pubDate><category /><enclosure ...
将所有媒体视为已更改为ns0
我正在使用 Python 3.6,有人知道如何修复它吗?或推荐不同的包装?