为了避免推文被 twitter 垃圾邮件过滤器捕获,我有一些代码会转到 tinyurl 并在每次为每个原始 url 运行代码时创建一个新的短 url。我想要的是每次'u'
打印时,它的值应该传递给一个变量'linkvar1', 'linkvar2', 'linkvar3'
等。这是稍后在代码中传递给推文提交的内容:
import simplejson
import httplib2
import twitter
import tinyurl
print("Python will now attempt to submit tweets to twitter...")
try:
api = twitter.Api(consumer_key='',
consumer_secret='',
access_token_key='',
access_token_secret='')
for u in tinyurl.create('http://audiotechracy.blogspot.co.uk/2014/03/reviewing-synapse-antidote-rack.html',
'http://audiotechracy.blogspot.co.uk/2014/03/free-guitar-patches-for-propellerhead.html',
'http://audiotechracy.blogspot.co.uk/2014/02/get-free-propellerhead-rock-and-metal.html',
):
print u
linkvar1 = u
linkvar2 = u
linkvar3 = u
status = api.PostUpdate("The new Synapse Antidote Rack Extension:" + linkvar1 + " #propellerhead #synapse")
status = api.PostUpdate("Free Propellerhead guitar patches for everyone!" + linkvar2 + " #propellerhead #reason #guitar")
status = api.PostUpdate("Free Metal and Rock drum samples!" + linkvar3 + " #propellerhead #reason)
print("Tweets submitted successfully!")
除了 Exception,e: print str(e)
print("Twitter 提交失败!!!")
然而,此时所有这些都是使用最后生成的 tinyurl 来提交所有推文。我敢肯定这是一个简单的解决方法,我只是觉得很愚蠢,但是有人知道如何做我想做的事吗?
谢谢