遁世潜龙乃上海人在广东 發表於 2025-6-16 00:00:00

帝国cms采集图文方法技巧

<p>帝国cms是我们用得比较多得PHP的建站系统,在建站过程中,如果自己没有信息源,只能靠手工不断的重复copy和粘贴,这样费时费力,于是我们就要使用帝国cms自带的采集功能来完成信息的录入。为了深入了解帝国cms采集功能,下面我们以&ldquo;新浪各地新闻&rdquo;栏目为例来进行实战采集。<br />  一、增加采集节点<br />  1、添加节点:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1.jpg" height="66" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141140259.jpg" width="132" /></p>
<p>&nbsp;<br />  2、选择要增加采集的栏目:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2.jpg" height="141" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141141E2.jpg" width="232" /></p>
<p>&nbsp;<br />  3、进入增加节点表单:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3.jpg" height="344" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141141452.jpg" width="613" /></p>
<p>&nbsp;<br />  4、在节点名称框里起个名字,然后把要采集的新浪各地新闻列表地址copy过来:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="4.jpg" height="164" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141141b2.jpg" width="469" /></p>
<p>&nbsp;<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="4-1.jpg" height="189" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141141603.jpg" width="616" /></p>
<p>&nbsp;<br />  5、下来发现好多选项,如&ldquo;采集页面地址方式二,内容页地址前缀...&rdquo;先不要理他,后面再一一详解,直接拉到 &ldquo;信息链接区域正则&rdquo;这里:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="5.jpg" height="320" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141141S0.jpg" width="615" /></p>
<p>&nbsp;<br />  6、这里是设置采集的列表信息链接区域正则,我们点击查看新浪各地新闻列表&ldquo;源文件&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="6.jpg" height="478" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141142V0.jpg" width="436" /></p>
<p>&nbsp;<br />  7、把源文件代码copy到Dreamweaver里,在Dreamweaver里选定要采集的信息链接区域:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="7.jpg" height="466" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-2506161411424N.jpg" width="616" /></p>
<p>&nbsp;<br />  8、切换到Dreamweaver代码方式,</p>
<ul><li>就是信息链接区域:<br />&nbsp;<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="8.jpg" height="302" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141142419.jpg" width="617" /></p>&nbsp;<br />  9、得到信息链接区域正则:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="9.jpg" height="135" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141142M6.jpg" width="612" /></p>&nbsp;<br />  10、得到信息页链接正则:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="10.jpg" height="134" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141143120.jpg" width="612" /></p>&nbsp;<br />  11、注意:如果信息页链接是相对地址,例如&lt; a href=&quot;/c/2012-03-05/205924063527.shtml&quot; target=&quot;_blank&quot; &gt;,那么&ldquo;内容页地址前缀&rdquo;要加域名:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="11.jpg" height="42" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141143126.jpg" width="475" /></p>&nbsp;<br />  12、现在要采集内容页的标题和内容:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="12.jpg" height="516" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141143431.jpg" width="615" /></p>&nbsp;<br />  13、查看新闻页&ldquo;源文件&rdquo;,找title标签:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="13.jpg" height="211" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141143501.jpg" width="547" /></p>&nbsp;<br />  14、取得标题正则:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="14.jpg" height="167" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141144264.jpg" width="572" /></p>&nbsp;<br />  15、这里是要采集的内容区域:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="15.jpg" height="178" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-2506161411442X.jpg" width="614" /></p>&nbsp;<br />  16、取得新闻内容正则:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="16.jpg" height="203" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-2506161411443U.jpg" width="490" /></p>&nbsp;<br />  (注意:新闻内容正则里的 d_id=&#39;*&#39; 用了通配符,因为每一篇新闻的d_id值是不同的,所以可以用*来代替它,&ldquo;*&rdquo;可以代替任意字符。)<br />  17、点击提交按钮就完成了整个采集节点:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="6-6.JPG" height="31" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141144516.jpg" width="86" /></p>&nbsp;<br />  二、预览采集节点是否正确<br />  1、提交按钮后返回管理节点:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="1.jpg" height="155" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141144401.jpg" width="615" /></p>&nbsp;<br />  2、点击&ldquo;预览&rdquo;采集,进入节点预览结果:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="2.jpg" height="120" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141145443.jpg" width="584" /></p>&nbsp;<br />  3、采集内容页列表<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="3.jpg" height="242" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141145432.jpg" width="614" /></p>&nbsp;<br />  4、采集内容页页面:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="4.jpg" height="356" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141145649.jpg" width="615" /></p>&nbsp;<br />  三、采集<br />  1、预览采集节点无误后,然后返回&ldquo;管理节点&rdquo;,点击&ldquo;开始采集&rdquo;链接就开始进行采集:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="1.jpg" height="155" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141145404.jpg" width="614" /></p>&nbsp;<br />  2、系统正在采集中:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="2.jpg" height="99" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141145S9.jpg" width="516" /></p>&nbsp;<br />  3、采集完后显示本地临时入库的信息,这时可以对临时入库的信息进行修改或者删除:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="3.jpg" height="352" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114A36.jpg" width="614" /></p>&nbsp;<br />  4、修改信息页面如图:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="4.jpg" height="451" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114C40.jpg" width="556" /></p>&nbsp;<br />  5、对采集的信息进行审核并入库,点击&ldquo;入库全部信息按钮&rdquo;:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="5.jpg" height="353" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114E28.jpg" width="615" /></p>&nbsp;<br />  6、确定操作:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="6.jpg" height="197" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141146112.jpg" width="262" /></p>&nbsp;<br />  7、信息入库完毕提示:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="7.jpg" height="128" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114L56.jpg" width="521" /></p>&nbsp;<br />  信息入库完毕后下来点击&rdquo;管理信息&ldquo;:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="8.jpg" height="102" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114K47.jpg" width="373" /></p>&nbsp;<br />  我们可以看到刚刚采集入库的新闻信息:<br />  <p><img style="max-width:100%!important;height:auto!important;"alt="9.jpg" height="389" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114H15.jpg" width="615" /></p>&nbsp;<br />  最后到&ldquo;数据更新&rdquo;刷新首页、栏目、和内容页就可以完成网站的信息采集了。由于帝国cms采集功能非常强大,一时半刻也说不完,下一页将继续讲解其他功能的使用和技巧。</li><br /><br /><br /><br />&nbsp;<li></li><li></li></ul>
<p>上一页我们介绍了帝国cms采集基本流程,那么我们这一讲介绍帝国cms如何采集内容分页。不少的同学在采集过程中,列表页和内容页都能可以很好地设定正则,但往往失败在内容分页正则上,主要是对内容分页正则不了解。帝国的内容分页形式有两种:(1)全部列出式(2)上下页导航式,但是这两种内容分页形式有什么区别,采集内容分页时该用哪种,官方说得比较模糊,对此有些同学感到很头大,好的,我们先看下例子:<br />  一、全部列出式<br />  全部列表式只需看第一页的页面HTML代码,这一页的所有分页链接都列出来了。<br />  1、我们以&ldquo;中华网内容分页(http://auto.china.com/dongtai/yejie/11012724/20120309/17081442.html)&rdquo;为例:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1.JPG" height="34" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114KD.jpg" width="216" /></p>
<p>&nbsp;<br />  可以看到这条新闻总共有3条分页。<br />  2、查看源代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2.jpg" height="164" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114H53.jpg" width="600" /></p>
<p>&nbsp;<br />  这一页里除了已经采集到的第1条分页外,还包括了第2条和第3条分页,所有的分页都列出来了。<br />  3、取得 分页区域正则([!--smallpageallzz--]):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3.JPG" height="221" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114W02.jpg" width="241" /></p>
<p>&nbsp;<br />  4、取得 分页链接正则([!--pageallzz--]):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="4.JPG" height="218" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114UK.jpg" width="242" /></p>
<p>&nbsp;<br />  二、上下页导航式<br />  上下页导航式是分页采集的难点,他需要所有页面都符合分页正则才行,在不熟悉的情况下,我们可以用第1页和第2页的代码来进行对比分析然后确定分页正则。<br />  1、我们以&ldquo;爱丽网内容分页(http://fashion.aili.com/76/445845.html)&rdquo;为例:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1.JPG" height="48" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114XN.jpg" width="569" /></p>
<p>&nbsp;<br />  可以看到这条新闻总共有20条分页。<br />  2、查看源代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-2.jpg" height="241" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114W31.jpg" width="526" /></p>
<p>&nbsp;<br />  这一页里除了已经采集到的第1条分页外,还包括了第2,第3,第4,第5,第6,第7,第8,第20条分页,但是第9到第19条分页并没有列出来,这时候我们拿用第1页和第2页的代码来进行对比分析,来确定分页正则:<br />  (1)第1页代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-2-1.jpg" height="241" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141149628.jpg" width="526" /></p>
<p>&nbsp;<br />  (2)第2页代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-2-2.jpg" height="254" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114b27.jpg" width="426" /></p>
<p>&nbsp;<br />  从这两幅图片可以看到他们有着相同的&ldquo;分页区域开始代码&rdquo;,&ldquo;分页链接&rdquo;格式,&ldquo;分页区域结束代码&rdquo;,那么就可以确定&ldquo;分页区域正则&rdquo;,&ldquo;分页链接正则&rdquo;。<br />  3、取得 分页区域正则([!--smallpageallzz--]):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-3.JPG" height="220" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-25061614114c41.jpg" width="238" /></p>
<p>&nbsp;<br />  4、取得 分页链接正则([!--pageallzz--]):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-4.jpg" height="219" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141149C8.jpg" width="237" /></p>
<p>&nbsp;<br />  5、为了方便教程显示,newstext我采集了标题而不是采集内容,预览结果:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-5.JPG" height="212" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141150153.jpg" width="600" /></p>
<p>&nbsp;<br />  注意事项:<br />  第一、在第一页的页面HTML代码里,内容分页链接全部列出来的情况下我们使用&ldquo;全部列出式&rdquo;。在第一页的页面HTML代码里,内容分页链接没有全部列出来的情况下我们使用&ldquo;上下页导航式&rdquo;。<br />  第二、用全部列出式时,采集规则正确但是莫名其妙的出现重复的分页,这时可以利用替换法把它过滤掉(下一讲我们再说)。<br />  第三、用上下页导航式时,老是采到第1页,其他页连个影子都没有见过,这是因为分页区域正则([!--smallpagezz--])截取错误。<br />  第四、用上下页导航式时,可以采集到前几页了,但是接下来这前几页全部重复循环到底,这也是因为分页区域正则([!--smallpagezz--])截取错误,截取范围过大,导致重复截取前几个分页链接。<br />  好的,这一讲就到这里,下一页我们主要介绍帝国cms采集过滤和替换。<br />前两讲我们分别介绍了帝国cms采集基本流程和帝国cms如何采集内容分页,最后这一讲主要介绍帝国cms采集过滤与替换,还有些技巧。<br />  一、过滤<br />  1、帝国cms采集过滤分为两种:<br />  (1)&ldquo;整体页面过滤正则&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-1-1.JPG" height="185" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141150912.jpg" width="614" /></p>
<p>&nbsp;<br />  (2)&ldquo;过滤广告正则&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-1-2.JPG" height="194" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141150642.jpg" width="616" /></p>
<p>&nbsp;<br />  我们有些疑惑,这两种过滤到底有什么区别?&ldquo;整体页面过滤正则&rdquo;是过滤整个网页的html代码。&ldquo;过滤广告正则&rdquo;是过滤文章内容,仅对文章内容([!--newstext--])起作用。<br />  2、过滤实例:<br />  过滤实例(1):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-2-1.jpg" height="298" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141150143.jpg" width="598" /></p>
<p>&nbsp;<br />&nbsp;<br />我们采集后发现信息内容底部多了行代码:&ldquo;</p>
<div style="clear:both; height:0; overflow:hidden; visibility:hiddden"></div>
<p>&rdquo;,根据格式&ldquo;广告开始[!--ad--]广告结束&rdquo;得到&ldquo;过滤广告正则<br />&rdquo;:<br />  </p>
<p></p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-2-2.JPG" height="189" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141151M3.jpg" width="615" /></p>
<p>&nbsp;<br />  过滤实例(2):<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-2-3.jpg" height="291" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141151621.jpg" width="596" /></p>
<p>&nbsp;<br />  要过滤链接代码怎么办,注意&ldquo;过滤广告正则&rdquo;右边有堆代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="1-2-4.jpg" height="190" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141151I1.jpg" width="619" /></p>
<p>&nbsp;<br />  鼠标先点击A,系统自动生成过滤链接代码&ldquo;,,,&rdquo;,这样就可以把采集后的内容链接过滤掉了。同理,如果想过滤其他html代码就点击相应的标签代码。<br /><br />  注意事项:当内容分页包含在内容([!--newstext--])里时,要过滤掉内容分页,否则会重复出现内容分页。<br />  二、替换<br />  1、帝国cms采集替换也分为两种:<br />  (1)&ldquo;整体页面替换&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1-1.JPG" height="182" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141151X6.jpg" width="612" /></p>
<p>&nbsp;<br />  (2)&ldquo;替换&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1-2.JPG" height="186" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141151X6.jpg" width="614" /></p>
<p>&nbsp;<br />  他们两种区别:&ldquo;整体页面替换&rdquo;是替换整个网页的html代码。&ldquo;替换&rdquo;是替换文章标题和内容,仅对标题([!--title--])和([!--newstext--])起作用。<br />  2、替换实例:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1-3.JPG" height="219" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-2506161411525Z.jpg" width="593" /></p>
<p>&nbsp;<br />  我们要把内容里的&ldquo;新华网&rdquo;替换成&ldquo;中华网&rdquo;:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1-4.JPG" height="182" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141152C8.jpg" width="613" /></p>
<p>&nbsp;<br />  预览下:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="2-1-5.jpg" height="208" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141152444.jpg" width="579" /></p>
<p>&nbsp;<br />  没有问题,替换过来了。<br />  三、图片采集<br />  (1)我们采集时会碰到信息内容可以正常采集,但是里面的图片却不显示,例子:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-1.jpg" height="323" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141152121.jpg" width="614" /></p>
<p>&nbsp;<br />  信息内容可以正常采集,就是图片不显示出来,这是由于内容图片的路径不对,图片的路径为相对地址。<br />  (2)查看源代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-2.jpg" height="399" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141153231.jpg" width="615" /></p>
<p>&nbsp;<br />  图片是相对地址,要换成绝对地址才能采集成功。<br />  (3)替换成绝对地址:<br />  先在目标站的图片右键查看属性:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-3-1.jpg" height="35" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141153554.jpg" width="358" /></p>
<p>&nbsp;<br />  目标站的图片地址为&ldquo;http://www.gdyd.com/news/PNews/a/e77366_634655073936250000.jpg&rdquo;,我们采集所到的图片地址为&ldquo;/news/PNews/a/e77366_634655073936250000.jpg&rdquo;,分析得到前缀&ldquo;http://www.gdyd.com&rdquo;,我们把前缀放到&ldquo;图片/FLASH地址前缀(内容)&rdquo;,如下图:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-3-2.JPG" height="30" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141153Y6.jpg" width="616" /></p>
<p>&nbsp;<br />  (4)前台预览图片:<br />  图片显示出来了:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-4-1.JPG" height="290" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141153209.jpg" width="593" /></p>
<p>&nbsp;<br />  查看源代码:<br />  </p>
<p><img style="max-width:100%!important;height:auto!important;"alt="3-4-2.JPG" height="235" src="https://zhuji.jb51.net/uploads/allimg/20250616/1-250616141153220.jpg" width="612" /></p>
<p>&nbsp;<br />  图片地址没错,是本地地址。<br />  注意事项:我们在采集预览和在本地临时入库信息时,发现已经添加了图片地址前缀了,但是图片还是不显示,出现这个你不用理他,直接入库,入库了系统才会自动添加图片地址前缀。<br />  至此采集实例讲解完毕,这三讲对帝国cms采集的基本流程,重点,难点基本都概括了,还有些基础的功能没能一一介绍清楚,大家可以到帝国官方网站看下基础教程。<br />  本文由 国外网站大全http://www.kguowai.com 原创,转载请注明出处,谢谢!</p>
<div class="clearfix"></div>
頁: [1]
查看完整版本: 帝国cms采集图文方法技巧