开发者

Display news from other web page

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"开发者_StackOverflow /></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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜