显示其他网页的新闻
我想将另一个网页上的新闻显示到我的网页上,但我无法找出最佳方法。
另一个网页上的新闻显示在 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>
我们非常欢迎所有建议。
// 尼堡
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要查看 PHP cURL 或 file_get_contents(安全问题)或查看 PHP HTML DOM 解析器。
还要看看你所做的事情是否合法? (如果他们想让你拥有内容,他们通常会提供 API)
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)