求一个能批量发布文章到wordpress的插件或工具
本帖最后由 firearmer 于 2012-1-7 17:02 编辑想找一个能批量定时发布文章的工具。
其实我自己已经找一上午了,找到了一些插件,例如Content As Txt、TXTAsPost 等等,可有个致命问题是,它只允许文本中的第一行作为标题,而我的则是文本名字就是标题,而Auto_Blog_Samurai_Pro这样的软件竟然功能也一样,所以只好求助大家了。
人多力量大,不知道哪位高人知道一款能批量导入txt或者直接批量定时发布文章到wordpress的插件或者工具啊?当然,最重要的一点是以文件名作为标题的。
PS:如果有一款软件可以批量将txt文本第一行插入标题,那也成,呵呵。 已经将可以批量将文件名变为标题的软件的下载地址pm给你了 如果你是用火车头采集的话 只需要把保存为html的规则设置为
[标签:标题]
[标签:tags]
[标签:内容]
然后配合
TXTAsPost 发布 你先把吧 文件名,写入文本,可能需要几行代码 来处理,你找找看看有现成的软件吗。再发布文本就行了 文本名做标题?这个真没见过,不过你可以到一些威客网站找人帮你改改手头的程序,有些程序稍微改动写应该可以实现,建议而已,我都是用的虫虫。{s_216_m} 我只知道火车头功能强大 别的楼下说 我用的是免费版,火车头确实是可以做到标题加文章的组合,但是,它是一口气把所有文章都弄到一个txt里的,另外,这样就没法伪原创了。
我想自己改改那个TXTAsPost插件,可是又不懂php,唉,书到用时方恨少啊。不知有哪位达淫能帮忙看看怎么改啊,先贴出代码了:<?php
/*
* Plugin Name: TXTAsPost
* Version: 1.8
* Plugin URI: http://www.s101.net/txt-as-post/
* Description: Import .txt as post in bulk
* Author: Jesse
* Author URI: http://www.s101.net/txt-as-post/
*/
require(dirname(__FILE__) . "/dUnzip2.inc.php");
class TXTAsPost {
/*Simple log*/
var $log='';
/*time interval retrieving from user input*/
var $interval='';
/*category retrieving from user input*/
var $post_category='';
/*tags retrieving from user input or second line of txt*/
var $tags_input='';
/* 0 means default process, 1 means fetch second line as date,2 means fetch second line as tags */
var $option=0;
/*default post type is post*/
var $post_type='post';
var $notify=0;
function TXTAsPost(){
add_action('admin_menu', array(&$this,'txtaspost_menu_setup'));
add_action('admin_footer',array(&$this,'txtaspost_js'));
}
function txtaspost_menu_setup() {
add_options_page('TxtAsPost Settings', 'TXT As Post', 10, __FILE__, array(&$this,'txtaspost_menu'));
if (isset($_FILES["zip"])) {
check_admin_referer( 'txtaspost_update'); // nonce
if (is_uploaded_file($_FILES['zip']['tmp_name'])) {
$this->txtaspost_process();
}
}
}
function txtaspost_process() {
//I need much time xD
set_time_limit(0);
$zipfilename = $_FILES['zip']['tmp_name'];
$zip = &new dUnzip2($zipfilename);
$zip->debug = false;
$list = $zip->getList();
shuffle($list);
$this->interval=absint($_POST['timeInterval']);
$this->post_category= $this->process_category($_POST['category']);
$this->post_type= $_POST['post_type'];
if($_POST['version'] == 'date')
$this->option=1;
else if($_POST['version'] == 'tags')
$this->option=2;
$this->tags_input= $_POST['tags'];
$tm = ($_POST['when']=='Now')?time() : ( $this->getLatestTime() + $this->interval*3600 );
//echo $this->getLatestTime() + $this->interval;
//echo date("Y-m-d H:i:s", $this->getLatestTime() + $this->interval);exit;
foreach($list as $filename => $b) {
$content = $zip->unzip($b['file_name']);
// Process each article
if($id=$this->process_content($content,$tm)){
// time will be associated with the time of latest post
$tm += strtotime($id->post_date) + $this->interval*3600 + rand(0,60);
}
else{
$this->log .= "Duplicate post: $filename <br />";
}
}
$this->notify=1;
}
function process_content($content,$post_date){
global $wpdb;
$content = str_replace("\n",'NEWLINE',$content);
$content=preg_replace('/[\x0-\x1F|\x7F-\xFF]/','',$content);
$content=str_replace('NEWLINE',"\n",$content);
$post = explode("\n",$content);
$post_title = $wpdb->escape(trim($post));
$i=1;
/*1 means fetch second line as date*/
if($this->option == 1){
$post_date = strtotime($post);
$i=2;
/*2 means fetch second line as tags*/
}else if($this->option == 2){
$this->tags_input=$wpdb->escape(trim($post));
$i=2;
}
$post_content = $wpdb->escape(trim( implode ( "\n" , array_slice( $post,$i ) ) ));
$post_name = sanitize_title( $post_title);
if (empty($post_title)||empty($post_content)) { return false; }
// Avoid duplicated post
if ( $wpdb->get_var( "SELECT post_title FROM $wpdb->posts WHERE post_title LIKE '$post_title' " )) {
return false;
}
$id=$this->txtaspost_post($post_title,$post_content,$post_name,$post_date);
return $id;
}
function txtaspost_post($post_title,$post_content,$post_name,$post_date) {
global $wpdb;
$id = wp_insert_post(array(
"post_title" => $post_title ,
"post_content" => $post_content,
"post_name" => $post_name,
"post_category" => $this->post_category,
"tags_input" => $this->tags_input,
"post_status" => "publish",
"post_author" => 1,
"post_type" => $this->post_type,
"post_date" => date("Y-m-d H:i:s", $post_date)
) );
return $id;
}
function process_category($category){
$cats=explode(",",$category);
$cats_id=array();
foreach($cats as $cat){
if($cat){
if( 0 == get_cat_id($cat) ){
if(!function_exists('wp_create_category')) include_once(ABSPATH.'wp-admin/includes/taxonomy.php');
// 0 means default category, if wp_create_category fail, return 0. nice. xD
array_push($cats_id,wp_create_category($cat));
}else
array_push($cats_id,get_cat_id($cat));
}//who cares if cat name is empty?
}
return array_unique($cats_id);
}
function getLatestTime() {
global $wpdb;
$post = $wpdb->get_results( "SELECT post_date FROM $wpdb->posts ORDER BY post_date DESC limit 0,1" );
$tm=strtotime($post->post_date);
// strtotime will return false if no post found
if(false == $tm)
$tm = time();
return $tm;
}
function txtaspost_menu() {
?>
<div class="wrap">
<?php
if( $this->notify ){
echo '<div id="message" class="updated fade"><p><a href="'. get_option("siteurl").'/wp-admin/edit.php">Edit post</a></p></div>';
}
?>
<h2>TXT As post</h2>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" enctype="multipart/form-data">
<?php wp_nonce_field('txtaspost_update'); ?>
<input type="hidden" name="action" value="update" />
<p>
<input type="radio" value="default" name="version" onclick="hidden(this.value);" checked/> Default Version
<input type="radio" value="date" name="version" onclick="hidden(this.value);"/> Custom Date Version
<input type="radio" value="tags" name="version" onclick="hidden(this.value);"/> Custom Tags Version<br />
</p>
<p>Upload zip file that contains plain text(.txt format files) <br />Format<br /><span id="promt" style="color:red;">1st line:<br />the rest:<br /></span></p>
<p>Upload Zip: <input type="file" name="zip" /> Maximum file size <?php echo ini_get('upload_max_filesize');?></p>
<div id="customDate">
<p>Time Interval by hours:<input type="text" name="timeInterval" value="8"/></p>
<p>Published time<br />
<input type="radio" name="when"value="Next" checked>According to the time of latest post<br />
<input type="radio" name="when"value="Now" >From Now On<br />
</p>
<p>Hint: the post date will be current servert time, if no post found.</p>
</div>
<div id="customTags">
<p>
Tags(separated by comma):<input type="text" name="tags" id="tags" value=""/>
</p>
</div>
<p>Category/Categories to post(separated by comma):<input type="text" id="category" name="category" value=""/></p>
<p>Hint: Category will automatically added if not exists.</p>
<p>
Post type: <select id="post_type" name="post_type">
<option value="post" selected="selected">post</option>
<option value="page" >page</option>
</select>
</p>
<p><input type="submit" class="button" value="Upload" /></p>
Error log:<br/>
<div id="log" style="color:red;"><?php echo $this->log;?></div>
</form>
</div>
<?php
}
function txtaspost_js(){
?>
<script type='text/javascript'>
function hidden(value){
if(value == 'tags'){
document.getElementById('customDate').style.display='';
document.getElementById('customTags').style.display='none';
document.getElementById('promt').innerHTML='1st line:\<br \/\>2nd line:tag a,tag b,tag c\<br \/\>the rest:';
}else if(value == 'date'){
document.getElementById('customDate').style.display='none';
document.getElementById('customTags').style.display='';
document.getElementById('promt').innerHTML='1st line:\<br \/\>2nd line:02/16/2009 8:53 am\<br \/\>the rest:';
}else if(value == 'default'){
document.getElementById('customTags').style.display='';
document.getElementById('customDate').style.display='';
document.getElementById('promt').innerHTML='1st line:\<br \/\>the rest:';
}
}
</script>
<?php
}
}
$txtaspost = & new TXTAsPost();
?>
回复 7# sembomb
兄弟,太感谢了!! WP都是用采集吧 一起来学习 回复 7# firearmer
火车头发布为HTML文件
然后批量改后缀,批量替换里边的一些符号 例如<P>
页:
[1]