我想将来自anoter网页的新闻显示在我的网页上,我无法找到最佳方法。
其他网页上的新闻显示在div类中,如下所示
<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>
我希望能够浏览新闻并将其显示在我自己的页面上,并根据我们自己的网站布局重新排列。
<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>
所有建议都非常受欢迎。
// Nyborg
答案 0 :(得分:1)
您需要查看PHP cURL或file_get_contents(安全问题)或查看PHP HTML DOM Parser。
还要看看你做什么的合法性? (如果他们想让你有内容,他们通常会提供API)