Tweepy - 我没有在推特上分享 Url,而是收到推文 link?
Tweepy - Instead of getting the Url shared in the twitter I'm getting the tweet link?
下面是我的代码。
写在Python V3
import tweepy
consumer_key="***"
consumer_secret="***"
access_key="***"
access_secret="***"
TweetCollection={}
def get_all_tweets(screen_name):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
alltweets = api.user_timeline(screen_name = screen_name, count = 20, include_entities = True)
for tweet in alltweets:
Id=tweet.id_str
PublishedAt=str(tweet.created_at)
Tweet=unescape(tweet.text)
ScreenName=screen_name
if tweet.entities['urls']!=[]:
StoryUrl=tweet.entities['urls'][0].get('url')
else:
StoryUrl=None
if Id is not None:
TweetCollection[Id]={'Tweet': Tweet, 'ScreenName': ScreenName, 'StoryUrl': StoryUrl, 'PublishedAt': PublishedAt}
get_all_tweets('SportIndustry')
print(TweetCollection={})
我需要 "t.co/PNMCqmC9Nw" 但我得到 "t.co/PQwP3WoSGL"
为什么?我应该怎么做才能解决这个问题?
我通过更改参数找到了方法。
alltweets = api.user_timeline(screen_name = screen_name, count = 20, include_entities = True, tweet_mode='extended')
还有
Tweet=unescape(tweet.full_text)
下面是我的代码。
写在Python V3
import tweepy
consumer_key="***"
consumer_secret="***"
access_key="***"
access_secret="***"
TweetCollection={}
def get_all_tweets(screen_name):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
alltweets = api.user_timeline(screen_name = screen_name, count = 20, include_entities = True)
for tweet in alltweets:
Id=tweet.id_str
PublishedAt=str(tweet.created_at)
Tweet=unescape(tweet.text)
ScreenName=screen_name
if tweet.entities['urls']!=[]:
StoryUrl=tweet.entities['urls'][0].get('url')
else:
StoryUrl=None
if Id is not None:
TweetCollection[Id]={'Tweet': Tweet, 'ScreenName': ScreenName, 'StoryUrl': StoryUrl, 'PublishedAt': PublishedAt}
get_all_tweets('SportIndustry')
print(TweetCollection={})
我需要 "t.co/PNMCqmC9Nw" 但我得到 "t.co/PQwP3WoSGL"
为什么?我应该怎么做才能解决这个问题?
我通过更改参数找到了方法。
alltweets = api.user_timeline(screen_name = screen_name, count = 20, include_entities = True, tweet_mode='extended')
还有
Tweet=unescape(tweet.full_text)