解析RSS - 但是在其中包含链接,以从链接页面获取图像

时间:2013-02-13 23:52:46

标签: php parsing rss

我正在学习RSS解析 - 实际上我对它很新。我想知道在php中接收RSS feed的概念。但是然后使用该RSS项链接,转到新页面,然后解析该页面以查找与其关联的图像(假设图像编号不同,但后续页面上的html没有)

这样的事情可能吗?没关系,我不是要求你提供具体信息/为我做这件事。这个概念只是一个简短的教育。

比如说这个网站: http://www.bulettings.com/

它有一个RSS Feed: http://www.bulettings.com/propertyrss

对每个项目说:

<item>
<title>
House Let @ &#163;2,400 per month, Chatsworth Rd, Charminster, BH8
</title>
<link>
http://www.bulettings.com/property/chatsworth-rd-charminster-bh8/buni-000690/1
</link>
<description>
<a href="http://www.bulettings.com/property/chatsworth-rd-charminster-bh8/buni-000690/1"><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5lor.jpg" width="150" alt="" align="left" border="0" /></a>STUDENT HOUSE - Large modernised seven bedroom House in Charminster with partial double glazing. Also has garden off road parking and bike storage.
</description>
<guid isPermaLink="true">
http://www.bulettings.com/property/chatsworth-rd-charminster-bh8/buni-000690/1
</guid>
<pubDate>Mon, 04 Feb 2013 14:02:13 GMT</pubDate>
<enclosure length="29" url="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5lor.jpg" type="image/jpg"/>
</item>

我收到了这些信息,但后来我说“转到”,它将我带到了以下来源的页面:

<script type="text/javascript">
    if(document.images){ 
 currentphoto=1; 
 maxphotos=7; 
    photo = new Array(7); 
    Imagetext = new Array(7); 
photo[1]=new Image();
photo[1].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5lor.jpg";
Imagetext[1] ="Photo 1";
photo[2]=new Image();
photo[2].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5svv.jpg";
Imagetext[2] ="Photo 2";
photo[3]=new Image();
photo[3].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5j86.jpg";
Imagetext[3] ="Photo 3";
photo[4]=new Image();
photo[4].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5vc2.jpg";
Imagetext[4] ="Photo 4";
photo[5]=new Image();
photo[5].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3pd0xwvp9.jpg";
Imagetext[5] ="Photo 5";
photo[6]=new Image();
photo[6].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5gq9.jpg";
Imagetext[6] ="Photo 6";
photo[7]=new Image();
photo[7].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5qhr.jpg";
Imagetext[7] ="Photo 7";
photo[8]=new Image();
photo[8].src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3mr0yds1e.jpg";
Imagetext[8] ="Photo 8";

 }
</script>

或进一步向下:

<ul>

<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5lor.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 4" title="Photo 4"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5svv.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 7" title="Photo 7"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5j86.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 3" title="Photo 3"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5vc2.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 8" title="Photo 8"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3pd0xwvp9.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 2" title="Photo 2"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5gq9.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 2" title="Photo 2"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3nm0z5qhr.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 6" title="Photo 6"/></li>
<li><img src="http://www.estateagentslive.net/pchomesdata/BOURNEMOUTHUNI/PHOTOS/buni-000690-p-w-3mr0yds1e.jpg" width="1024" height="768" onmouseover="document.images['photoview'].src = this.src;" alt="Photo 1" title="Photo 1"/></li>
</ul>

所以它会从rss获取该信息,以及有关它的信息,把它放在某个地方并去除所有垃圾,然后将它留给图像链接。然后转到下一个项目。

能做到吗?

1 个答案:

答案 0 :(得分:1)

我会使用simplepie将Feed分成可访问的部分。它非常易于使用。

get_enclosure可能是您想要关注的内容。

Here's a "getting started" example表示使用它是多么容易。