增加Twython Twitter API直接消息发送速度

时间:2014-01-17 01:34:03

标签: python twitter twython

我正在使用Twython创建一段python代码,用于在我启动后尽快发送DM。但是,使用我当前的方法,它目前大约需要5秒钟才能同时发送10条直接消息。

我的代码如下:

from twython import Twython
APP_KEY = "xxxxxxx"
APP_SECRET = "xxxxxxx"

OAUTH_TOKENEJOR = 'xxxxx'
OAUTH_TOKEN_SECRETEJOR = 'xxxxx'
OAUTH_TOKENAUSTIN = 'xxxxxxx'
OAUTH_TOKEN_SECRETAUSTIN = 'xxxxxxxxx'
OAUTH_TOKENSTEPH = 'xxxxxxx'
OAUTH_TOKEN_SECRETSTEPH = 'xxxxxxx'
OAUTH_TOKENFRANCO = 'xxxxxxx'
OAUTH_TOKEN_SECRETFRANCO = 'xxxxxxxx'
OAUTH_TOKENDUY = 'xxxxxxxx'
OAUTH_TOKEN_SECRETDUY = 'xxxxxxxxxx'
OAUTH_TOKENQUY = 'xxxxxxxxxx'
OAUTH_TOKEN_SECRETQUY = 'xxxxxxxxxxx'
startTime = datetime.now()

twitteraustin = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENAUSTIN, OAUTH_TOKEN_SECRETAUSTIN)
twitterfranco = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENFRANCO, OAUTH_TOKEN_SECRETFRANCO)
twittersteph = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENSTEPH, OAUTH_TOKEN_SECRETSTEPH)
twitterejor = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENEJOR, OAUTH_TOKEN_SECRETEJOR)
twitterduy = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENDUY, OAUTH_TOKEN_SECRETDUY)
twitterquy = Twython(APP_KEY, APP_SECRET, OAUTH_TOKENQUY, OAUTH_TOKEN_SECRETQUY)


twitterfranco.send_direct_message(screen_name="vphuoc", text= ' hello! ')
twitterfranco.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitteraustin.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitteraustin.send_direct_message(screen_name="vphuoc", text= ' hello!')
twittersteph.send_direct_message(screen_name="vphuoc", text= ' hi!')
twittersteph.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterejor.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterejor.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterduy.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterduy.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterquy.send_direct_message(screen_name="vphuoc", text= ' hello!')
twitterquy.send_direct_message(screen_name="vphuoc", text= ' hello!')

print ("DM SENT IN")
print (datetime.now()-startTime)

我有一个相当快的互联网连接(80 Mps向下/向上)所以我想知道是否有任何方式我可以格式化我的代码使发送DM更快

谢谢!

0 个答案:

没有答案