求一个能批量发布文章到wordpress的插件或工具

  [复制链接]
查看: 2629   回复: 10
发表于 2012-1-7 15:44:55 | 显示全部楼层 |阅读模式
10T币
本帖最后由 firearmer 于 2012-1-7 17:02 编辑

想找一个能批量定时发布文章的工具。

其实我自己已经找一上午了,找到了一些插件,例如Content As Txt、TXTAsPost 等等,可有个致命问题是,它只允许文本中的第一行作为标题,而我的则是文本名字就是标题,而Auto_Blog_Samurai_Pro这样的软件竟然功能也一样,所以只好求助大家了。

人多力量大,不知道哪位高人知道一款能批量导入txt或者直接批量定时发布文章到wordpress的插件或者工具啊?当然,最重要的一点是以文件名作为标题的。
PS:如果有一款软件可以批量将txt文本第一行插入标题,那也成,呵呵。

最佳答案

查看完整内容

已经将可以批量将文件名变为标题的软件的下载地址pm给你了
发表于 2012-1-7 15:44:56 | 显示全部楼层
已经将可以批量将文件名变为标题的软件的下载地址pm给你了
回复

使用道具 举报

发表于 2012-1-7 17:16:47 | 显示全部楼层
如果你是用火车头采集的话 只需要把保存为html的规则设置为
[标签:标题]
[标签:tags]
[标签:内容]

然后配合
TXTAsPost 发布
回复

使用道具 举报

发表于 2012-1-7 19:58:13 | 显示全部楼层
你先把吧 文件名,写入文本,可能需要几行代码 来处理,你找找看看有现成的软件吗。再发布文本就行了
回复

使用道具 举报

发表于 2012-1-7 20:19:31 | 显示全部楼层
文本名做标题?这个真没见过,不过你可以到一些威客网站找人帮你改改手头的程序,有些程序稍微改动写应该可以实现,建议而已,我都是用的虫虫。求一个能批量发布文章到wordpress的插件或工具
回复

使用道具 举报

发表于 2012-1-8 09:33:50 | 显示全部楼层
我只知道火车头功能强大 别的楼下说
回复

使用道具 举报

 楼主| 发表于 2012-1-8 10:09:04 | 显示全部楼层
我用的是免费版,火车头确实是可以做到标题加文章的组合,但是,它是一口气把所有文章都弄到一个txt里的,另外,这样就没法伪原创了。
我想自己改改那个TXTAsPost插件,可是又不懂php,唉,书到用时方恨少啊。不知有哪位达淫能帮忙看看怎么改啊,先贴出代码了:
  1. <?php

  2. /*
  3. * Plugin Name:   TXTAsPost
  4. * Version:       1.8
  5. * Plugin URI:    http://www.s101.net/txt-as-post/
  6. * Description:   Import .txt as post in bulk
  7. * Author:        Jesse
  8. * Author URI:    http://www.s101.net/txt-as-post/
  9. */

  10. require(dirname(__FILE__) . "/dUnzip2.inc.php");

  11. class TXTAsPost {
  12.                
  13.                 /*Simple log*/
  14.                 var $log='';

  15.                 /*time interval retrieving from user input*/
  16.                 var $interval='';
  17.                
  18.                 /*category retrieving from user input*/
  19.                 var $post_category='';

  20.                 /*tags retrieving from user input or second line of txt*/
  21.                 var $tags_input='';

  22.                 /* 0 means default process, 1 means fetch second line as date,2 means fetch second line as tags */
  23.                 var $option=0;

  24.                 /*default post type is post*/
  25.                 var $post_type='post';

  26.                 var $notify=0;

  27. function TXTAsPost(){

  28. add_action('admin_menu', array(&$this,'txtaspost_menu_setup'));
  29. add_action('admin_footer',array(&$this,'txtaspost_js'));
  30. }

  31. function txtaspost_menu_setup() {
  32.    add_options_page('TxtAsPost Settings', 'TXT As Post', 10, __FILE__, array(&$this,'txtaspost_menu'));
  33.        
  34.    
  35. if (isset($_FILES["zip"])) {
  36.         check_admin_referer( 'txtaspost_update'); // nonce
  37.       if (is_uploaded_file($_FILES['zip']['tmp_name'])) {
  38.         $this->txtaspost_process();
  39.       }
  40.    }

  41. }

  42.        
  43. function txtaspost_process() {
  44.    
  45.    //I need much time xD
  46.    
  47.    set_time_limit(0);
  48.    $zipfilename = $_FILES['zip']['tmp_name'];
  49.    $zip = &new dUnzip2($zipfilename);
  50.    $zip->debug = false;
  51.    $list = $zip->getList();
  52.    shuffle($list);


  53.    $this->interval=absint($_POST['timeInterval']);
  54.    $this->post_category= $this->process_category($_POST['category']);
  55.    $this->post_type= $_POST['post_type'];

  56.    

  57.    if($_POST['version'] == 'date')
  58.         $this->option=1;
  59.    else if($_POST['version'] == 'tags')
  60.         $this->option=2;
  61.        

  62.    $this->tags_input= $_POST['tags'];

  63.    $tm = ($_POST['when']=='Now')?  time() : ( $this->getLatestTime() + $this->interval*3600 );

  64.   //  echo $this->getLatestTime() + $this->interval;
  65. //echo        date("Y-m-d H:i:s", $this->getLatestTime() + $this->interval);exit;
  66.       foreach($list as $filename => $b) {

  67.               $content = $zip->unzip($b['file_name']);

  68.                 // Process each article
  69.                if($id=$this->process_content($content,$tm)){
  70.                        
  71.                       // time will be associated with the time of latest post
  72.                       $tm += strtotime($id->post_date) + $this->interval*3600 + rand(0,60);
  73.         }
  74.         else{
  75.                
  76.                 $this->log .= "Duplicate post: $filename <br />";               
  77.                
  78.         }

  79.     }
  80.         $this->notify=1;
  81.        
  82.           
  83.       

  84.   
  85. }
  86. function process_content($content,$post_date){
  87.        
  88.         global $wpdb;

  89.         $content = str_replace("\n",'NEWLINE',$content);
  90.         $content=preg_replace('/[\x0-\x1F|\x7F-\xFF]/','',$content);
  91.         $content=str_replace('NEWLINE',"\n",$content);
  92.         $post = explode("\n",$content);
  93.            $post_title = $wpdb->escape(trim($post[0]));
  94.         $i=1;
  95.        
  96.           
  97.         /*1 means fetch second line as date*/
  98.         if($this->option == 1){
  99.        
  100.                 $post_date = strtotime($post[1]);       
  101.                 $i=2;
  102.         /*2 means fetch second line as tags*/
  103.         }else if($this->option == 2){

  104.                 $this->tags_input=$wpdb->escape(trim($post[1]));
  105.                 $i=2;

  106.         }

  107.         $post_content = $wpdb->escape(trim( implode ( "\n" , array_slice( $post,$i ) ) ));
  108.         $post_name = sanitize_title( $post_title);
  109.            if (empty($post_title)||empty($post_content)) { return false; }

  110.            // Avoid duplicated post
  111.            if ( $wpdb->get_var( "SELECT post_title FROM $wpdb->posts WHERE post_title LIKE '$post_title' " )) {
  112.                              return false;
  113.            }

  114.         $id=$this->txtaspost_post($post_title,$post_content,$post_name,$post_date);
  115.        
  116.         return $id;

  117. }
  118. function txtaspost_post($post_title,$post_content,$post_name,$post_date) {
  119.    global $wpdb;

  120. $id = wp_insert_post(array(
  121.       "post_title" => $post_title ,
  122.       "post_content" => $post_content,
  123.       "post_name" => $post_name,       
  124.       "post_category" => $this->post_category,
  125.       "tags_input" => $this->tags_input,
  126.       "post_status" => "publish",                       
  127.       "post_author" => 1,
  128.       "post_type" => $this->post_type,
  129.       "post_date" => date("Y-m-d H:i:s", $post_date)
  130.    ) );

  131.    return $id;
  132. }

  133. function process_category($category){

  134.         $cats=explode(",",$category);
  135.         $cats_id=array();
  136.         foreach($cats as $cat){
  137.                     if($cat){       
  138.                         if( 0 == get_cat_id($cat) ){

  139.                                 if(!function_exists('wp_create_category')) include_once(ABSPATH.'wp-admin/includes/taxonomy.php');

  140.                                 // 0 means default category, if wp_create_category fail, return 0. nice. xD
  141.                                 array_push($cats_id,wp_create_category($cat));
  142.                         }else
  143.                                 array_push($cats_id,get_cat_id($cat));
  144.                 }//who cares if cat name is empty?
  145.         }
  146.         return array_unique($cats_id);

  147. }
  148. function getLatestTime() {
  149.         global $wpdb;
  150.                
  151.         $post = $wpdb->get_results( "SELECT post_date FROM $wpdb->posts ORDER BY post_date DESC limit 0,1" );
  152.         $tm=strtotime($post[0]->post_date);
  153.        
  154.        
  155.         // strtotime will return false if no post found
  156.         if(false == $tm)
  157.                 $tm = time();
  158.         return $tm;
  159.                
  160. }
  161.        
  162. function txtaspost_menu() {

  163.    ?>
  164.    <div class="wrap">
  165. <?php
  166. if( $this->notify ){

  167.         echo        '<div id="message" class="updated fade"><p><a href="'. get_option("siteurl").'/wp-admin/edit.php">Edit post</a></p></div>';
  168. }
  169. ?>
  170.       <h2>TXT As post</h2>
  171.         <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" enctype="multipart/form-data">
  172.      <?php wp_nonce_field('txtaspost_update'); ?>
  173.      <input type="hidden" name="action" value="update" />
  174. <p>
  175. <input type="radio" value="default" name="version" onclick="hidden(this.value);" checked/> Default Version
  176. <input type="radio" value="date" name="version" onclick="hidden(this.value);"  /> Custom Date Version
  177. <input type="radio" value="tags" name="version" onclick="hidden(this.value);"  /> Custom Tags Version<br />
  178. </p>
  179.       <p>Upload zip file that contains plain text(.txt format files) <br />Format<br /><span id="promt" style="color:red;">1st line:[title]<br />the rest:[content]<br /></span></p>

  180.    
  181.       
  182.          <p>Upload Zip: <input type="file" name="zip" /> &nbsp;Maximum file size <?php echo ini_get('upload_max_filesize');?></p>
  183.       
  184.       <div id="customDate">
  185.       <p>Time Interval by hours:<input type="text" name="timeInterval" value="8"/></p>
  186.        <p>Published time<br />
  187.                   <input type="radio" name="when"  value="Next" checked>According to the time of latest post<br />
  188.                   <input type="radio" name="when"  value="Now"       >From Now On<br />
  189.         </p>
  190.      <p>Hint: the post date will be current servert time, if no post found.</p>
  191.      </div>

  192.       
  193.        
  194.       <div id="customTags">
  195.       <p>
  196.        Tags(separated by comma):<input type="text" name="tags" id="tags" value=""/>
  197.       </p>

  198.       </div>

  199.      <p>Category/Categories to post(separated by comma):<input type="text" id="category" name="category" value=""/></p>
  200.       <p>Hint: Category will automatically added if not exists.  </p>
  201.       
  202.        <p>
  203.          Post type: <select id="post_type" name="post_type">
  204.                         <option value="post" selected="selected">post</option>
  205.                         <option value="page"                        >page</option>
  206.                     </select>
  207.       </p>
  208.       
  209.          
  210.       <p><input type="submit" class="button" value="Upload" /></p>
  211.       Error log:<br/>
  212.         <div id="log" style="color:red;"><?php echo $this->log;?></div>
  213.   </form>
  214.    </div>
  215.    <?php
  216. }

  217. function txtaspost_js(){
  218. ?>
  219. <script type='text/javascript'>
  220. function hidden(value){
  221.        
  222.        
  223.         if(value == 'tags'){
  224.                 document.getElementById('customDate').style.display='';
  225.                 document.getElementById('customTags').style.display='none';
  226.                 document.getElementById('promt').innerHTML='1st line:[title]\<br \/\>2nd line:tag a,tag b,tag c\<br \/\>the rest:[content]';
  227.         }else if(value == 'date'){
  228.                 document.getElementById('customDate').style.display='none';
  229.                 document.getElementById('customTags').style.display='';
  230.                 document.getElementById('promt').innerHTML='1st line:[title]\<br \/\>2nd line:02/16/2009 8:53 am\<br \/\>the rest:[content]';
  231.         }else if(value == 'default'){
  232.                 document.getElementById('customTags').style.display='';
  233.                 document.getElementById('customDate').style.display='';
  234.                 document.getElementById('promt').innerHTML='1st line:[title]\<br \/\>the rest:[content]';
  235.                
  236.         }


  237. }
  238. </script>
  239. <?php

  240. }
  241. }
  242. $txtaspost = & new TXTAsPost();




  243. ?>
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-1-11 10:15:50 | 显示全部楼层
回复 7# sembomb


    兄弟,太感谢了!!
回复

使用道具 举报

发表于 2012-2-19 13:20:27 | 显示全部楼层
WP都是用采集吧
回复

使用道具 举报

发表于 2012-3-5 23:46:20 | 显示全部楼层
一起来学习
回复

使用道具 举报

发表于 2012-3-7 13:17:54 | 显示全部楼层
回复 7# firearmer

火车头发布为HTML文件
然后批量改后缀,批量替换里边的一些符号 例如<P>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

firearmer

楼主