欢迎来到素材无忧网,按 + 收藏我们
登录 注册 退出 找回密码

织梦用火车头采集器采集文章后自动生成首页、栏目页、上下篇

时间: 2019-04-21 19:32 阅读: 作者:素材无忧网

  织梦使用火车头采集器采集数据,发布文档后是不会自动生成首页、上下篇、栏目页的,我们可以给织梦dedecms添加自动生成代码来实现,先普及下织梦火车头采集器知识:

  火车头是一款可以大量采集原创文章的软件。

  火车头采集器有哪些好处?

  1、通用性强

  无论新闻、论坛、视频、黄页、图片、下载类网站,只要通过浏览器能看到的结构化的内容,通过指定匹配规则,都能采集到您所需要的内容。

  2、稳定、高效

  七年磨一剑,软件不断更新进步,采集速度快,性能稳定,占用资源少。

  3、扩展性强、适用范围广

  自定义web发布,自定义主流的数据库的保存和发布,自定义本地php及.net外部编程接口处理数据,让数据都能为你所用。

  

       实现教程

  打开 /dede/inc/inc_archives_functions.php 最下面加入3个函数

/*火车头采集自动更新主页*/
  function MakeIndex()
  {
  global $dsql,$cfg_basedir,$cfg_templets_dir,$cfg_df_style;
  require_once(DEDEINC.'/arc.partview.class.php');
  $envs = $_sys_globals = array();
  $envs['aid'] = 0;
  $pv = new PartView();
  $row = $pv->dsql->GetOne('SELECT * FROM `dede_homepageset`');
  $templet = str_replace("{style}", $cfg_df_style, $row['templet']);
  $homeFile = dirname(__FILE__).'/../'.$row['position'];
  $homeFile = str_replace("//", "/", str_replace("\\", "/", $homeFile));
  $fp = fopen($homeFile, 'w') or die("无法更新网站主页到:$homeFile 位置");
  fclose($fp);
  $tpl = $cfg_basedir.$cfg_templets_dir.'/'.$templet;
  if(!file_exists($tpl))
  {
  $tpl = $cfg_basedir.$cfg_templets_dir.'/default/index.htm';
  if(!file_exists($tpl)) exit("无法找到主页模板:$tpl ");
  }
  $GLOBALS['_arclistEnv'] = 'index';
  $pv->SetTemplet($tpl);
  $pv->SaveToHtml($homeFile);
  $pv->Close();
  }
  /*火车头采集自动更新栏目www.lol9.cn织梦六久阁*/
  function MakeParentType($typeid)
  {
  global $dsql;
  $typediarr = array();
  array_push($typediarr,$typeid);
  $row3 = $dsql->GetOne("Select reid,topid From `dede_arctype` where id=".$typeid);
  if(!in_array($row3['reid'],$typediarr) and $row3['reid']!=0) array_push($typediarr,$row3['reid']);
  if(!in_array($row3['topid'],$typediarr) and $row3['topid']!=0) array_push($typediarr,$row3['topid']);
  require_once(DEDEDATA."/cache/inc_catalog_base.inc");
  require_once(DEDEINC."/channelunit.func.php");
  require_once(DEDEINC."/arc.listview.class.php");
  foreach($typediarr as $typeid)
  {
  $lv = new ListView($typeid);
  $lv->MakeHtml(1,$maxpagesize);
  }
  }
  /*火车头采集自动更新上下篇*/
  function MakePreNext($aid,$typeid)
  {
  global $dsql;
  require_once(DEDEINC.'/arc.archives.class.php');
  $aid = intval($aid);
  $preRow = $dsql->GetOne("SELECT id FROM `dede_arctiny` WHERE id<$aid AND arcrank>-1 AND typeid='$typeid' ORDER BY id DESC");
  $nextRow = $dsql->GetOne("SELECT id FROM `dede_arctiny` WHERE id>$aid AND arcrank>-1 AND typeid='$typeid' ORDER BY id ASC");
  if(is_array($preRow))
  {
  $envs['aid'] = $preRow['id'];
  $arc = new Archives($preRow['id']);
  $arc->MakeHtml();
  }
  if(is_array($nextRow))
  {
  $envs['aid'] = $nextRow['id'];
  $arc = new Archives($nextRow['id']);
  $arc->MakeHtml();
  }
  }

 

  继续在这个文件中找到

  return $revalue;

  在它的下面加入

  MakePreNext($arcID,$typeid);

  MakeIndex();

  MakeParentType($typeid);

  添加完后是这样的

织梦用火车头采集器采集文章后自动生成首页、栏目页、上下篇

  这样添加好后,无论你用火车头免登录接口还是WEB发布模块,无论是普通文章模型还是图集模型还是软件模型,都可以自动生成相关静态文件了。

版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

转载请注明: 织梦用火车头采集器采集文章后自动生成首页、栏目页、上下篇

标签:  
模板推荐