如何用autoit批量自动发推(tweets)

by 李笑来 on 2009/11/29

in Auto-It

AutoIt是个简单易用的Windows环境脚本语言。今天写了个用AutoIt+cURL+Proxy组合起来批量发推的脚本(一定要注册个新的帐号测试,今天我刷屏20条,被tinyfool鄙视了……):

$tusername = "type-your-username-here"
$tpassword = "type-your-password-here"
$proxy = "127.0.0.1:9666"
$textfile = "textfilename-containing-one-tweets-per-line"
$inteval = 60000
 
$file = FileOpen($textfile, 128)
While 1
	$line = FileReadLine($file)
	If StringLen($line)>140 Then $line=StringLeft($line, 140)
	_TwitterUpdateStatus($line)
	ConsoleWrite($line & @CRLF)
	Sleep($inteval)
WEnd
MsgBox(0, "", "finished!")
 
Func _TwitterUpdateStatus($message)
	Run('curl -x ' & $proxy & ' -u ' & $tusername & ':' & $tpassword & ' -d "status=' & _UnicodeURLEncode($message) 	& '" http://twitter.com/statuses/update.xml', "", @SW_HIDE)
EndFunc
 
Func _UnicodeURLEncode($UnicodeURL)
    $UnicodeBinary = StringToBinary ($UnicodeURL, 4)
    $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
    $UnicodeBinaryLength = StringLen($UnicodeBinary2)
    Local $EncodedString
    For $i = 1 To $UnicodeBinaryLength Step 2
        $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2)
        If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar, 4)) Then
            $EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar)
        Else
            $EncodedString &= '%' & $UnicodeBinaryChar
        EndIf
    Next
    Return $EncodedString
EndFunc

AutoIt在这里下载;其它必要文件在这里下载(含以上代码)。

{ 10 comments… read them below or add one }

1 captain 2009/11/30 at 01:01

支持下  ,沙发

Reply

2 新东方胖子 2009/11/30 at 01:51

这个语法 完全等于 php+asp 混合
还有curl
有点意思哈,呵呵 谢谢分享

Reply

3 sss 2009/11/30 at 09:03

看不懂,能否加点注释?

Reply

4 菠萝 2009/11/30 at 09:15

不错!

Reply

5 zcc 2009/11/30 at 09:16

我接收到几条老外发的,带了@指向
就是因为我的用户名太短了~

Reply

6 yaoeryi 2009/11/30 at 11:28

不知道笑来老师现在用什么方法上twitter呢?

follow me on twitter: yaoeryi

Reply

7 pc 2009/11/30 at 23:01

笑来兄
不是吧,点你的下载
居然有特洛伊木马!!!
 

Reply

8 李笑来 2009/12/01 at 08:19

to pc, 晕。我安装的是360杀毒,查过。唉,那你就不要用了。反正代码都在那里。如果是检测出u96.exe有毒,那可能是误报。

follow me on twitter: xiaolai

Reply

9 viphhs 2009/12/02 at 13:08

1、呵呵,360杀毒。建议笑来先生试试这个http://www.avast.com/
2、这是捷克(布拉格)的一家杀毒软件公司的产品。有家用免费版。
下载地址:http://www.avast.com/cns/download-avast-home.html
所获奖项:http://www.avast.com/cns/awards.html
请点这个,“由于连接关系,中国地区用户直接从我们网站下载所需时间可能较长. ”
不要单击大大的“马上下载”(从IT168上面下载)的那个图标。我试过,那个是个试用版。
3、下载后,只要在下载地址页面的注册那里注册一下。就可以免费使用一年。一年后同样步骤,即可使用第二年。
所有过程,均无需付费。唯一需要注意的就是,“家用”。

Reply

10 李笑来 2009/12/02 at 13:10

过去的两三年里我一直在用avast。只是最近想换换360试试看。

follow me on twitter: xiaolai

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: