如果您使用的是 JQuery,则可以使用以下代码:
<!doctype html>
<html>
<head>
<title>Property Agents</title>
</head>
<body>
<!-- including JQuery from google CDN -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<div class="content">
<div class="rss">
<!-- here is your script, which will paste here news-->
<script src="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fajaxplorer.info%2Ffeed&chan=title&num=10&date=y&utf=y&html=y"></script>
</div>
</div>
<script>
$(document).ready(function(){
var text,pos;
$('.rss-item').each(function(){
// getting html of each element
text = $(this).html();
// search text in item
pos = text.indexOf('AjaXplorer 4.2');
// found? then hide it
if (pos != -1) $(this).hide();
});
});
</script>
</body>
</html>
此代码查找所有带有“AjaXplorer 4.2”文本的新闻并将其隐藏。
完整的工作示例(只是为了确保它正在工作)你可以在
http://pastehtml.com/view/car52rb92.html看到
声明者:
这不是一个好的解决方案。更好地使用 PHP 生成页面并在服务器端过滤这些新闻。这很容易,伙计。可能是 10-20 行代码。
php-solution 的想法很简单:
1. 从 url 获取数据file_get_contents
2. 然后通过行并找到你需要的内容(使用 SimpleXML 更好地解析)
3. 用一行代码在 HTML 页面中输出修改后的数据,例如<?php echo %text ?>