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

by xiaolai on 2009/11/29 · 13 comments

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在这里下载;其它必要文件在这里下载(含以上代码)。

{ 13 comments… read them below or add one }

captain November 30, 2009 at 01:01

支持下  ,沙发

Reply

新东方胖子 November 30, 2009 at 01:51

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

Reply

sss November 30, 2009 at 09:03

看不懂,能否加点注释?

Reply

菠萝 November 30, 2009 at 09:15

不错!

Reply

zcc November 30, 2009 at 09:16

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

Reply

yaoeryi November 30, 2009 at 11:28

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

Reply

pc November 30, 2009 at 23:01

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

Reply

李笑来 December 1, 2009 at 08:19

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

Reply

viphhs December 2, 2009 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

李笑来 December 2, 2009 at 13:10

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

Reply

风变绿 June 14, 2010 at 09:18

传说360后台窃取用户信息
这事老师知道吗?

Reply

Vibram Five Fingers shoes September 18, 2010 at 11:22

Searching for the profitable tracking system may be quite difficult in case that you are not sure about the things you are going to need along the process; for instance, if your company is highly interested in getting the GPS Fleet Tracking system, you may search the web in order to find the necessary professional assistance that will install the wanted device. The following tips are to be followed in order to make sure that your company will make the best choice ever. ]For instance, the internet is to be browsed in order to get all the necessary results and information concerning vibram shoes the existing companies that may provide you with the GPS Fleet Tracking. There are various options that are to be considered by every company in order to make a profitable deal; you may also use the auction sites in order to get the necessary equipment because using these sites means that you will save your time and money. Therefore, your company should take full advantage of the advanced technology that is to be found on the current market; this technology is especially designed in order to help your company navigate through all kinds of roads without having to worry about the safety of the drivers. These tracking systems are to be used in order to get rid of the constant need of country maps and information. The fleet managements has to be done in the proper manner <a href…

Reply

@xuwenming May 24, 2011 at 23:29

太不应该 笑来竟然用360 。。。

Reply

Leave a Comment

Previous post:

Next post: