我的Python代码无法从RSS提要中解析“描述”,当我运行以下脚本时,它会显示多行空格,我怎么才能正确解析它?
import feedparser
import unidecode
rss_url = "http://my.blogspot.com/feeds/posts/default?alt=rss"
feed = feedparser.parse( rss_url )
for key in feed["entries"]:
print unidecode.unidecode(key["description"])
RSS说明部分:
<description><iframe src="https://domain.com/embed/NTXFZhHw/01-10-1080p.mp4" scrolling="no" frameborder="0" width="700" height="430" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe> </description>
答案 0 :(得分:3)
请替换:
import feedparser
使用:
import feedparser
feedparser._HTMLSanitizer.acceptable_elements.update(['iframe'])