作为业余爱好项目,我正在开发基于 WindowsForm 的 RSS 聚合器。我在浏览器控件中显示包含 html 的 RSS 提要的描述时遇到问题。
导致我遇到问题的描述示例:
"<img border=\"0\" src=\"//images10.newegg.com/NeweggImage/ProductImageCompressAll125/14-487-346-Z01.jpg\" width=\"125\" height=\"94\" title=\"\" alt=\"\">
问题是img src。如果我在它前面添加 http:
,它就可以很好地加载图像。否则,我得到一个 x 盒,不幸的是不是那种你可以用来玩游戏的盒。
解决方法是解析每个描述并在必要的地方添加 http:
字符串,但这似乎有很多不必要的编码,而且每个 feed 都会不同。
有没有更好的方法来显示用 html 格式化的 RSS Feed 数据,或者有没有办法用 webbrowser 控件解决上述问题?
最佳答案
How to show the RSS Feed data that's formatted with HTML?
不知道有没有办法。
Is there a way to fix the issue described above with the webbrowser control?
您可以使用 jquery 轻松解析所有在 http:
之前的 img 的 src 属性:
$(function() {
$('img').attr('src', function(index, src) {
return 'http:' + this.getAttribute('src');
});
});
关于c# - RSS 提要中以 "//"开头的 URL 未加载到 WebBrowser 控件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46046968/