다음 코드는 거의 올바르게 작동합니다. 3 개의 URL을 짧게하고 3 개의 다른 트윗 내용을 입력 한 다음 트위터에 제출합니다. 그러나 URL이 짧아 질 때마다 단축 URL은 동일합니다. 이 때문에 트윗은 트위터 스팸 필터에 의해 계속 잡히고 있습니다.단축 URL은 임의로 지정해야합니다.
단축 URL의 모양을 무작위로 선택하여 가져 오기 tinyurl 또는 일부 다른 방법을 사용하여이를 방지 할 수 있습니까?
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 submissions have failed!!!")
감사합니다 당신이 tinyurl.create
의 결과를 통해 루프, 당신은 세 가지 linkvar
변수마다 그것을 할당하고
가능한 중복 (http://stackoverflow.com/questions/22898046/struggling-with-a-series-of-variables) –