我尝试使用此示例从http://www.nydailynews.com/cmlink/NYDN.Article.rss获取图像 url
但没有成功
你能帮我找到所有正确的方法来按SyndicationItem
类从 RSS 提要中获取所有可能的图像 URL 吗?
这里有草案解决方案,但我想应该是更通用的解决方案。
谢谢!
List<RssFeedItem> rssItems = new List<RssFeedItem>();
Stream stream = e.Result;
XmlReader response = XmlReader.Create(stream);
SyndicationFeed feeds = SyndicationFeed.Load(response);
foreach (SyndicationItem f in feeds.Items)
{
RssFeedItem rssItem = new RssFeedItem();
rssItem.Description = f.Summary.Text;
foreach (SyndicationLink enclosure in f.Links.Where<SyndicationLink>(x => x.RelationshipType == "enclosure"))
{
Uri url = enclosure.Uri;
long length = enclosure.Length;
string mediaType = enclosure.MediaType;
rssItem.ImageLinks.Add(url.AbsolutePath);
}
}