数字化技能提升教程,数字化时代生存宝典

数字化百科 / 词条 / CMSware内容页采集规则定义

CMSware内容页采集规则定义

查看全部词条命名空间:Main

导航:返回上一页


内容页的采集规则数量多少取决与内容模型字段数量的多少以及你想采集的项目数量的多少,一般来说,新闻采集只需采集新闻的标题和内容,那样就只需要定2个规则,让我们往下看:

cmsware122.gif

要正确定义标题和内容的采集规则,我们需要考察内容页的网页源代码

cmsware123.gif

我们发现网页的</nowiki>包含了新闻的标题,所以标题的采集规则很容易就定下来了<br /> <pre><br /> /<Title>(.*)<\/Title>/isU==>[clearHTML]</p> <p>这里,我们使用==>[clearHTML]来进行内容过滤,也就是过滤掉标题中的所有html代码,比如字体大小颜色定义等.<br /> </pre><br /> 下面让我们接着确定内容的采集规则,我们继续考察源代码 <br /> <div><br /> <span class="wiki-file"><img src="/w/images/cmsware124.gif" alt="cmsware124.gif" loading="lazy" decoding="async"></span><br /> </div><br /> 通过研究内容周围的<a href="/wiki/HTML">HTML</a>,我们确定了采集规则的头标识和尾标识分别为<nowiki><font id="Zoom"> 和 </font></nowiki> ,于是,内容采集规则定为 <br /> <pre><br /> /<font id=\"Zoom\">(.*) <\/font>/isU==>[clearRubbish,1]</p> <p>这里,我们使用==>[clearRubbish,1]来进行内容过滤,第一个参数clearRubbish是用来去除内容中的垃圾代码,比如 flash广告,js广告等,而第2个参数是用来定义是否对<br /> 内容中的图片进行本地化,在这里我们设为1,即内容图片本地化</p> <p>注意:我们使用 <\/font>作为尾标识可能有欠妥当的地方,因为很可能内容中还会出现<font></font>的定义,那样就可能出现问题,此时我们需要更准确的规则定义:</p> <p>/<font id=\"Zoom\">(.*)<\/font>\s\r[\s]*<table/isU==>[clearRubbish,1] <br /> </pre><br /> 标题和内容的采集规则都确定下来了,现在我们再点测试,系统显示有效内容页地址解析结果,然后我们对一条结果进行解析,解析结果如下:<br /> <div><br /> <span class="wiki-file"><img src="/w/images/cmsware125.gif" alt="cmsware125.gif" loading="lazy" decoding="async"></span><br /> </div><br /> 好了,所有测试通过,让我们开始运行我们的爬虫,开始采集</p> <h2>参考来源</h2> <ul> <li><a href="http://www.lonmo.com/cmsware/manual/" rel="nofollow noopener">参考来源</a></li> </ul> <p><a href="/wiki/category%3ACMSware">category:CMSware</a></p></div> </div> <div class="wiki-category-footer"> 分类: <a href="https://zzbaike.ichuanghui.cn/wiki/%E5%88%86%E7%B1%BB:CMSware">CMSware</a> </div> </article> </main> </div> </div> </main> <footer class="footer"> <div class="footer-main"> <div class="wrap footer-grid"> <div> <a class="footer-brand" href="https://zzbaike.ichuanghui.cn"> <span class="footer-brand-text">站长百科</span> </a> <p class="footer-desc">站长百科是成立于2007年的一个服务于数字化技能人才的综合性网站,以“数字化技能提升教程 、数字化时代生存宝典”作为网站的理念,提供一站式的数字化领域教程及百科全书式的知识讲解。</p> </div> <div class="footer-group"> <div class="footer-title">网站导航</div> <nav> <a href="https://zzbaike.ichuanghui.cn/wiki/">数字化百科</a> <a href="https://zzbaike.ichuanghui.cn/jz">建站程序</a> <a href="https://zzbaike.ichuanghui.cn/kf">开发</a> <a href="https://zzbaike.ichuanghui.cn/fwq">服务器</a> <a href="https://zzbaike.ichuanghui.cn/bg">办公软件</a> </nav> </div> <div class="footer-group"> <div class="footer-title">关于我们</div> <nav> <a href="https://zzbaike.ichuanghui.cn/ads.html">广告服务</a> <a href="https://zzbaike.ichuanghui.cn/contact">联系我们</a> <a href="https://zzbaike.ichuanghui.cn/sitemap.html">网站地图</a> <a href="https://zzbaike.ichuanghui.cn/announce.html">免责声明</a> <a href="https://zzbaike.ichuanghui.cn/partner.html">合作伙伴</a> </nav> </div> <div class="footer-qrs"> <div class="footer-qr"> <div class="footer-qr-title">联系我们</div> <img alt="广告合作" src="/storage/uploads/2026/08/NLKczU075dPB1jXH0z0LvVzHNHyL0gorJDQUJLgG.png" decoding="async" width="396" height="396" loading="lazy"> <p>广告合作</p> </div> <div class="footer-qr"> <div class="footer-qr-title">交流群</div> <img alt="QQ群号:4114653" src="/storage/uploads/2026/08/W4VwbOf7tCIG8RujCa7Qo8rqAxnKac5VjjBvLNGn.png" decoding="async" width="220" height="220" loading="lazy"> <p>QQ群号:4114653</p> </div> </div> </div> </div> <div class="footer-bottom"> <div class="wrap footer-bottom-inner"> <span>Copyright © 2007 - 2026 zzbaike.com, All Rights Reserved</span> </div> </div> </footer> </body> </html>