2010-09-01 73 views
0

您是否知道如何使用罗密解析器解析图像?(java平台)我在罗马解析器文档中查看了一些示例,但很明显。你能否通过使用rome rss解析器提供示例代码来解析图像?如何使用罗马解析图像RSS解析器

问候 Altaico

+0

请添加国税发要解析RSS一些实例绘制图像,这是不完全清楚你的图片,外壳,HTML内容或媒体RSS是什么意思。 – 2010-09-01 13:30:56

回答

0

罗马是一个RSS解析器/发电机。因此,它与图像解析无关。但是,如果某个RSS源的内容是HTML,那么您可以将其视为罗马的有效扩展,即抓取图像内容。

作为一个例子,考虑从宏伟的brother bricks网站这个RSS Feed项目:

<item> 
    <title>From the unknown chasms of space</title> 
    <link>http://feedproxy.google.com/~r/TheBrothersBrick/~3/8g6XnrwJDlQ/</link> 
    <comments>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/#comments</comments> 
    <pubDate>Wed, 01 Sep 2010 04:20:49 +0000</pubDate> 
    <dc:creator>Nannan</dc:creator> 
      <category><![CDATA[LEGO]]></category> 
    <category><![CDATA[Our Own Creations]]></category> 
    <category><![CDATA[Space]]></category> 

    <guid isPermaLink="false">http://www.brothers-brick.com/?p=16929</guid> 
    <description><![CDATA[&#8230;comes my latest creation, a ship called Broken Regret. I strove for an ominous and organic looking craft by incorporating curves and spikes (best viewed on black). The result is something that looks much better in real life than on photos. This is due to the curves of the ship distorting our perception of its [...]]]></description> 
     <content:encoded><![CDATA[<p>&#8230;comes my latest creation, a ship called Broken Regret. I strove for an ominous and organic looking craft by incorporating curves and spikes (best <a href=http://bighugelabs.com/onblack.php?id=4946649495&#038;size=large>viewed on black</a>). The result is something that looks much better in real life than on photos. This is due to the curves of the ship distorting our perception of its true shape and size (I had to do a lot of lens adjustments in Photoshop). Hopefully you&#8217;ll see what I mean when I post more pictures and a video in the upcoming days.</p> 
<p><a href="http://www.flickr.com/photos/nannanz/4946649495/"><img src="http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg" width="500"></a></p> 
<p>On another note, I want to mention that there are some incredible sellers on Bricklink who sent me last-minute parts to complete the ship at practically no cost. I&#8217;ve encountered many of you over the years, you know who you are, thank you.</p> 
<img src="http://feeds.feedburner.com/~r/TheBrothersBrick/~4/8g6XnrwJDlQ" height="1" width="1"/>]]></content:encoded> 
     <wfw:commentRss>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/feed/</wfw:commentRss> 
    <slash:comments>0</slash:comments> 
    <feedburner:origLink>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/</feedburner:origLink></item> 

您可能会注意到内容:编码标签包含一个链接到Flickr的图像:http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg,一些RSS客户端能够显示为图像。然而,这并不是因为他们正确地解析RSS提要,而是因为除了能够正确解释RSS流之外,他们还能够解释其内容(在这种情况下,表示要呈现的条目的某个HTML片段)。因此,具有下载和打开图像文件的能力不是RSS解析的问题,而是正确解释RSS内容的问题,这不是RSS本身,而是编码的CDATA,一个是能够解析的理解为任何形式的有效内容(在本例中为HTML)。

+0

这是不正确。有一个可用于图像的规范:http://www.w3schools.com/rss/rss_tag_image.asp – Marc 2012-07-03 17:04:46

+0

@Marc对不起,但在我看来你的评论是不是由任何fa shion比我的回答更正确:您提供的标签解释了一个RSS阅读器如何显示RSS提要的图像(例如,该提要的图标),而我试图解释如何阅读嵌入到一个RSS中的图像条目。换句话说,你的评论完全补充了我的答案。 – Riduidel 2012-07-05 12:58:29

0

你看到图像的URL在标签中。 所以试着在你的程序中解析这个标签(只需在解析标题,pubDate,链接等处添加另一个标签)。 然后创建一个methot getContent将标记中的所有内容保存在一个String中。 并从那里只是做一个StringTokenizer的,让您的图片链接(选择分隔符\”)

你得到URL后,下载

搜索图片供下载的位图RSS,你会发现如何下载与位图和程序