0

I want to display news from anoter web page onto mine, and I cannot figure out the best method for this.

The news on the other web page are displayed within a div class like the following

<div class="news-container"> 
<div class="news-list"><a href="news/1/" title="abcd"><img src="abcd.jpg" /><strong>abcd</strong></a> 
    <p>What you see is what you get. <span class="morelink"><a href="news/1/" title="abcd">Read more</a></span></p> 
    <div class="clear-both"></div> 
</div> 
<div class="news-list"><a href="news/2/" title="efgh"><img src="efgh.jpg" /><strong>efgh</strong></a> 
    <p>What you see is what you get. <span class="morelink"><a href="news/3/" title="abcd">Read more</a></span></p> 
    <div class="clear-both"></div> 
</div> 
<div class="news-list"><a href="news/3/" title="ijkl"><img src="ijkl.jpg" /><strong>ijkl</strong></a> 
    <p>What you see is what you get. <span class="morelink"><a href="news/3/" title="abcd">Read more</a></span></p> 
    <div class="clear-both"></div> 
</div> 
<div class="news-list"><a href="news/4/" title="mnop"><img src="mnop.jpg" /><strong>mnop</strong></a> 
    <p>What you see is what you get. <span class="morelink"><a href="news/4/" title="abcd">Read more</a></span></p> 
    <div class="clear-both"></div> 
</div>

I would like to be able to circle through the news and display them on my own page and rearranged according to our own site layout.

<div class="other-news"> 
<div class="news-list"><strong>abcd</strong>
    <p>What you see is what you get. <a href="news/1/" title="abcd"><img src="abcd.jpg" /></a></p> 
</div> 
<div class="news-list"><strong>efgh</strong>
    <p>What you see is what you get. <a href="news/3/" title="abcd"><img src="efgh.jpg" /></a> </p> 
</div> 
<div class="news-list"><strong>ijkl</strong>
    <p>What you see is what you get. <a href="news/3/" title="abcd"><img src="ijkl.jpg" /></a> </p> 
</div> 
<div class="news-list"><strong>mnop</strong>
    <p>What you see is what you get. <a href="news/4/" title="abcd"><img src="mnop.jpg" /></a> </p>
</div>

All suggestions are more than welcome.

// Nyborg

1 Answer 1

1

You need to look at PHP cURL or file_get_contents(security issues) or look at PHP HTML DOM Parser.

Also look at the legality of what your doing? (they normally provide an API if they want to let you have content)

2
  • Legality has been checked. Head office does not have man power to do the task (!). I have looked at PHP cURL and DOM parser, but I am not sure which one could do the job the simplest way. Suggestions are welcome.
    – Nyborg
    Commented Feb 1, 2011 at 15:17
  • No problem then. Just use one of the methods above, i do recommend the HTLM DOM Parser - simplehtmldom.sourceforge.net Commented Feb 1, 2011 at 15:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.