显示其他网页的新闻

发布于 2024-10-15 10:17:49 字数 2542 浏览 1 评论 0原文

我想将另一个网页上的新闻显示到我的网页上,但我无法找出最佳方法。

另一个网页上的新闻显示在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海风掠过北极光 2024-10-22 10:17:49

您需要查看 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文