Auto posting wordpress blogs using perl

<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

#This script is aimed to do auto post for wordpress. Tested with wp 2.5

# on windows XP, activestate perl 5.8.820 with IEAutomation module installed.

#put all your articles/blogs in the folder $DIR. The script will use the file name

#as post title (without file extension, of course). Suppose you save your articles

#as .txt files, otherwise edit the statement “$post_title = substr($file,0,length($file)-4);”

#to get correct file name. For txt or htm, use length($file)-4, for html, use -5, and so on.



use Win32::IEAutomation;



#*******************       Define variables     *****************



$post_url = “http://netrancher.0fees.net/wp-admin/post-new.php”;

$DIR = ‘C:/download’;



&wplogin;



#************ open dirctory to read each files in it*************



opendir DH, $dir or die “cannot open dir $DIR: $!/n”;

foreach $file (readdir(DH)) {

next if $file eq “.”;

next if $file eq “..”;

open FH,”$DIR//$file” or warn “cannot open file $file: $!/n”;

undef $/;

$con = <FH>;

$/ = “/n”;



#******************* determine which category to put this file to



undef $cat_is,$cat_itc,$cat_os;

undef $cat_cs,$cat_git,$cat_net;

undef $cat_ai,$cat_db,$cat_pl;



if ($file =~ /network|wireless|wi-fi|wimax| lan | wan |/) {$cat_net = “0″}

if ($file =~ /Linux|unix|UNIX|[wW]indows|ubuntu|redhat|solaris/) {$cat_os = “0″}

if ($file =~ /certification|guide|cssip|ccna|ccnp|ccie|ocp|mcse|scsa/) {$cat_itc = “0″}

if ($file =~ /mysql|mssql| SQL | sql |oracle|database/) {$cat_db = “0″}

if ($file =~ /security|secur|forensic|hack|crack|authentic/) {$cat_is = “0″}

if ($file =~ /aritifical|intelligence|fuzzy|mind|brain|human/) {$cat_ai = “0″}

if ($file =~ /science|computing|architecture|computational|algorithmic|genetic/) {$cat_cs =”0″}

if ($file =~ /program|perl|python|developer|ruby|j2ee|j2se|java|vb|/.net/) {$cat_pl = “0″}

if ($file =~ /access|excel|office|word|powerpoint|sap|performance|troubleshoot|windows/) {$cat_git = “0″}



#*************  prepare other variables for post ************

#

$post_title = substr($file,0,length($file)-4);



#************************ open IE to post-new.php*************

#*

$ie=Win32::IEAutomation->new(”Maximize =>1″,”Visiable => 1″);

$ie->gotoURL($post_url);

$ie->WaitforDone();

$ie->getTextBox(’name:’,”post_title”)->SetValue($post_title);

$ie->getButton(’id:’,”edButtonHTML”)->click();

$ie->getTextArea(’name:’,”content”)->SetValue($con);

sleep(2);



#************************ set post category ********************



if (defined $cat_ai) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”artifical intelligence”);}

if (defined $cat_db) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”Database”);}

if (defined $cat_git) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”General IT”);}

if (defined $cat_is) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”information security”);}

if (defined $cat_itc) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”IT certification”);}

if (defined $cat_net) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”networking”);}

if (defined $cat_os) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”Operating System”);}

if (defined $cat_pl) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”Programming Language”);}

if (defined $cat_cs) {

$ie->getSelectList(’id:’,”newcat_parent”)->SelectItem(”Computer Science”);}



#************************* set publish status *******************

#

sleep(2);

$ie->getSelectList(’name:’,”post_status”)->SelectItem(”Published”);



#************************ click the publish button **************

#

$ie->getButton(’id:’,”publish”)->click();



}



sub wplogin {



$myie = Win32::IEAutomation->new(”maximize => 1″,”visible => 1″);

$myie->gotoURL(”http://netrancher.0fees.net/wp-login.php”);

$myie->getTextBox(’id:’,”user_login”)->SetValue(”netrancher”);

$myie->getTextBox(’id:’,”user_pass”)->SetValue(”yourpassword”);

$myie->getButton(’name:’,”wp-submit”)->click();

sleep(3);

$myie->closeIE();



}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值