ツイートが 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!")
except Exception,e: print str(e)
print("Twitterへの送信に失敗しました!!!")
ただし、現時点では、送信されたすべてのツイートに対して最後に生成された tinyurl を使用するだけです。これは私が馬鹿げているだけの簡単な修正だと確信していますが、私が望むことを行う方法を知っている人はいますか?
ありがとう