Python TwitterAPI搜索返回被截断的tweets

Python TwitterAPI搜索返回被截断的tweets,python,twitter,python-twitter,Python,Twitter,Python Twitter,我正试图构建一个python程序来获取基于某个关键字的推文。然而,虽然我可以成功地检索推文,但它们会被截断 如何获取推文的全文 代码:(代码下面的示例输出) (python推特模块) 样本输出: created_at: Wed Apr 11 20:55:25 +0000 2018 favorite_count: 1573 hashtags: [] id: 984173096566341632 id_str: 984173096566341632 lang: en retweet_count: 1

我正试图构建一个python程序来获取基于某个关键字的推文。然而,虽然我可以成功地检索推文,但它们会被截断

如何获取推文的全文

代码:(代码下面的示例输出) (python推特模块)

样本输出:

created_at: Wed Apr 11 20:55:25 +0000 2018
favorite_count: 1573
hashtags: []
id: 984173096566341632
id_str: 984173096566341632
lang: en
retweet_count: 1480
source: <a href="https://about.twitter.com/products/tweetdeck" rel="nofollow">TweetDeck</a>
**text**: Caution: Disturbing video. Car speeds through red light, striking pedestrian during vigil Wednesday for cyclist kil… **SHORTENEDURLHERE**
truncated: True
urls: [{'expanded_url':'https://twitter.com/i/web/status/984173096566341632', 'url':**SHORTENEDURLHERE**}]
user: {'created_at': 'Wed Nov 14 17:43:42 +0000 2007', 'description': 'KTLA has been keeping Southern California informed since 1947. \n\nHave great video, photos or story tips? Share with us using #ktla.', 'favourites_count': 1078, 'followers_count': 717397, 'friends_count': 769, 'geo_enabled': True, 'id': 10252962, 'id_str': '10252962', 'lang': 'en', 'listed_count': 3885, 'location': 'Los Angeles, CA', 'name': 'KTLA', 'profile_background_color': '040718', 'profile_background_image_url': 'http://pbs.twimg.com/profile_background_images/507323957578436608/olqcU4MS.jpeg', 'profile_background_image_url_https': 'https://pbs.twimg.com/profile_background_images/507323957578436608/olqcU4MS.jpeg', 'profile_banner_url': 'https://pbs.twimg.com/profile_banners/10252962/1369959990', 'profile_image_url': 'http://pbs.twimg.com/profile_images/809849913240481792/YQ0aT9hv_normal.jpg', 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/809849913240481792/YQ0aT9hv_normal.jpg', 'profile_link_color': '24009C', 'profile_sidebar_border_color': 'FFFFFF', 'profile_sidebar_fill_color': '95E8EC', 'profile_text_color': '3C3940', 'profile_use_background_image': True, 'screen_name': 'KTLA', 'statuses_count': 144937, 'time_zone': 'Pacific Time (US & Canada)', 'url': '**SHORTENEDURLHERE**', 'utc_offset': -25200, 'verified': True}
user_mentions: []
#############################################
创建时间:2018年4月11日星期三20:55:25+0000 最受欢迎人数:1573 标签:[] id:984173096566341632 id_街:984173096566341632 朗:嗯 转发次数:1480 资料来源: **文本**:警告:干扰视频。在周三为自行车手kil守夜时,汽车超速闯红灯,撞到行人…**SHORTENEDURLHERE** 是的 url:[{'expanded_url':'https://twitter.com/i/web/status/984173096566341632“,”url:**SHORTENEDURLHERE**}] 用户:{'created_at':'Wed Nov 14 17:43:42+0000 2007','description':'KTLA自1947年以来一直在向南加州通报情况。\n\n有好的视频、照片或故事提示吗?请使用#KTLA','Favorites_count':1078,'followers_count':717397,'friends_count':769,'geo_enabled':True,'id':10252962,'id#str':'10252962,'lang':'en',“列表计数”:3885,“位置”:“加利福尼亚州洛杉矶”,“名称”:“KTLA”,“个人资料背景颜色”:“040718”,“个人资料背景图像url”:”http://pbs.twimg.com/profile_background_images/507323957578436608/olqcU4MS.jpeg“,”个人资料\u背景\u图像\u url\u https':”https://pbs.twimg.com/profile_background_images/507323957578436608/olqcU4MS.jpeg","教授,ile_banner_url':'https://pbs.twimg.com/profile_banners/10252962/1369959990“,“配置文件\图像\ url”:”http://pbs.twimg.com/profile_images/809849913240481792/YQ0aT9hv_normal.jpg“,”配置文件\图像\ url\ https':”https://pbs.twimg.com/profile_images/809849913240481792/YQ0aT9hv_normal.jpg“,”配置文件链接颜色“:”24009C“,”配置文件侧栏颜色“:”FFFFFF,“配置文件侧栏填充颜色”:“95E8EC”,“配置文件文本颜色”:“3C3940”,“配置文件使用背景图像”:True,“屏幕名称”:“KTLA”,“状态计数”:144937,“时区”:“太平洋时间(美国和加拿大)”,“url”:“**SHORTENEDURLHERE**”,“utc偏移量”:-25200,“已验证”:True} 用户提到:[] #############################################
初始化Api时,只需通过
tweet\u mode='extended'

import twitter
api = twitter.Api(consumer_key=CONSUMER_KEY,
                  consumer_secret=CONSUMER_SECRET,
                  access_token_key=ACCESS_TOKEN,
                  access_token_secret=ACCESS_SECRET,
                  tweet_mode='extended')
results = api.GetSearch(term="car", since="2018-04-11", until="2018-04-12", count=5)

for twt in results:
    tempTweet = (str(twt))
tweet = json.loads(tempTweet)

print(tweet)
这将打印

{u'lang': u'en', u'full_text': u'Have you ever been in so much trouble that you\u2019ve narrowed your options down to a. Winning the lottery b. Wrapping your car around a telephone pole and c. Giving the creepy neighborhood millionaire the date he keeps pestering for at  Cheescake Factory? \nPffffffttt. Me either. <twitter link>', u'media': [{u'expanded_url': u'https://twitter.com/_jkate/status/984219542061703168/photo/1', u'sizes': {u'large': {u'h': 1280, u'w': 719, u'resize': u'fit'}, u'small': {u'h': 680, u'w': 382, u'resize': u'fit'}, u'medium': {u'h': 1200, u'w': 674, u'resize': u'fit'}, u'thumb': {u'h': 150, u'w': 150, u'resize': u'crop'}}, u'url': u'<twitter link>', u'media_url_https': u'https://pbs.twimg.com/media/Daimc02VQAAulWe.jpg', u'display_url': u'pic.twitter.com/ZfCeeZN4g0', u'type': u'photo', u'id': 984219532733530112, u'media_url': u'http://pbs.twimg.com/media/Daimc02VQAAulWe.jpg'}], u'created_at': u'Wed Apr 11 23:59:59 +0000 2018', u'hashtags': [], u'user_mentions': [], u'source': u'<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>', u'id_str': u'984219542061703168', u'urls': [], u'retweet_count': 2, u'id': 984219542061703168, u'favorite_count': 83, u'user': {u'profile_use_background_image': True, u'id': 492519212, u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg', u'profile_sidebar_fill_color': u'F3F3F3', u'profile_text_color': u'333333', u'followers_count': 13069, u'location': u'United States', u'profile_background_color': u'EBEBEB', u'id_str': u'492519212', u'utc_offset': -21600, u'statuses_count': 1543, u'description': u'Illegitimate love child of digital marketing and \u2615\ufe0f. Instagram: <twitter link>', u'friends_count': 11470, u'profile_link_color': u'990000', u'profile_image_url': u'http://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg', u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme7/bg.gif', u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/492519212/1509938057', u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme7/bg.gif', u'screen_name': u'_jkate', u'lang': u'en', u'favourites_count': 8060, u'name': u'\U0001f319J Kate \U0001f4ab', u'created_at': u'Tue Feb 14 20:23:54 +0000 2012', u'time_zone': u'Mountain Time (US & Canada)', u'profile_sidebar_border_color': u'DFDFDF', u'listed_count': 55}}
{u'lang':u'en',u'full_text':你有没有遇到过如此多的麻烦,以至于你把你的选择缩小到a.中奖b.把你的车绕在电线杆上,c.给这个令人毛骨悚然的邻居百万富翁一个他一直在芝士蛋糕工厂纠缠的日子?\nPffffffttt.我也是[{u'扩展的url':u'https://twitter.com/_jkate/status/984219542061703168/photo/1“,u'h':{u'h':{u'h':1280,u'w':719,u'resize':u'fit'},u'small':{u'h':680,u'w':382,u'resize':u'fit'},u'Middle':{u'h':1200,u'w':674,u'resize':u'fit'},u'thumb':{u'h':150,u'w':u'resize crop'},u'url':u',u'media\u url\u https':u'https://pbs.twimg.com/media/Daimc02VQAAulWe.jpg'u'display_url':u'pic.twitter.com/ZfCeeZN4g0',u'type':u'photo',u'id':984219532733530112,u'media_url':u'http://pbs.twimg.com/media/Daimc02VQAAulWe.jpg“}”,u'created_at':u'Wed Apr 11 23:59:59+0000 2018',u'hashtags':[],u'user_notes':[],u'source':u'',u'id_str':u'984219542061703168',u'url':[],u'retweet_count':2,u'id':984219542061703168,u'favorite_count':83,u'user':{u'profile\u use\u background\u image':True,u'id':492519212,u'profile\u image\u url\u https':u'https://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg“,u'profile\u sidebar\u fill\u color':u'f3f3',u'profile\u text\u color':u'333333',u'followers\u count':13069,u'location':u'status',u'profile\u background\u color':u'ebebebebebebebeb',u'id\u str”:u'492519212',u'utc_offset':-21600,u'statuses_count':1543,u'description':u'digital marketing和\u2615\ufe0f.Instagram的私生子,u'friends_count':11470,u'profile_link_color':u'990000',u'profile_image_url':u'http://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg“,u”配置文件\u背景\u图像\u url_https':u'https://abs.twimg.com/images/themes/theme7/bg.gif“,u'profile\u banner\u url”:u'https://pbs.twimg.com/profile_banners/492519212/1509938057“,u'profile\u background\u image\u url”:u'http://abs.twimg.com/images/themes/theme7/bg.gif“,u'screen'u name':u'u jkate',u'lang':u'en',u'favorites'u count':8060,u'name':u'\U0001f319J Kate\U0001f4ab',u'c”创建时间:2012年2月14日星期二20:23:54+0000,时区:山地时间(美国和加拿大),侧边栏颜色:u'DFDFDF',列表计数:55}

初始化Api时,只需通过
tweet\u mode='extended'

import twitter
api = twitter.Api(consumer_key=CONSUMER_KEY,
                  consumer_secret=CONSUMER_SECRET,
                  access_token_key=ACCESS_TOKEN,
                  access_token_secret=ACCESS_SECRET,
                  tweet_mode='extended')
results = api.GetSearch(term="car", since="2018-04-11", until="2018-04-12", count=5)

for twt in results:
    tempTweet = (str(twt))
tweet = json.loads(tempTweet)

print(tweet)
这将打印

{u'lang': u'en', u'full_text': u'Have you ever been in so much trouble that you\u2019ve narrowed your options down to a. Winning the lottery b. Wrapping your car around a telephone pole and c. Giving the creepy neighborhood millionaire the date he keeps pestering for at  Cheescake Factory? \nPffffffttt. Me either. <twitter link>', u'media': [{u'expanded_url': u'https://twitter.com/_jkate/status/984219542061703168/photo/1', u'sizes': {u'large': {u'h': 1280, u'w': 719, u'resize': u'fit'}, u'small': {u'h': 680, u'w': 382, u'resize': u'fit'}, u'medium': {u'h': 1200, u'w': 674, u'resize': u'fit'}, u'thumb': {u'h': 150, u'w': 150, u'resize': u'crop'}}, u'url': u'<twitter link>', u'media_url_https': u'https://pbs.twimg.com/media/Daimc02VQAAulWe.jpg', u'display_url': u'pic.twitter.com/ZfCeeZN4g0', u'type': u'photo', u'id': 984219532733530112, u'media_url': u'http://pbs.twimg.com/media/Daimc02VQAAulWe.jpg'}], u'created_at': u'Wed Apr 11 23:59:59 +0000 2018', u'hashtags': [], u'user_mentions': [], u'source': u'<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>', u'id_str': u'984219542061703168', u'urls': [], u'retweet_count': 2, u'id': 984219542061703168, u'favorite_count': 83, u'user': {u'profile_use_background_image': True, u'id': 492519212, u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg', u'profile_sidebar_fill_color': u'F3F3F3', u'profile_text_color': u'333333', u'followers_count': 13069, u'location': u'United States', u'profile_background_color': u'EBEBEB', u'id_str': u'492519212', u'utc_offset': -21600, u'statuses_count': 1543, u'description': u'Illegitimate love child of digital marketing and \u2615\ufe0f. Instagram: <twitter link>', u'friends_count': 11470, u'profile_link_color': u'990000', u'profile_image_url': u'http://pbs.twimg.com/profile_images/985737787306422273/aJykLNLj_normal.jpg', u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme7/bg.gif', u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/492519212/1509938057', u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme7/bg.gif', u'screen_name': u'_jkate', u'lang': u'en', u'favourites_count': 8060, u'name': u'\U0001f319J Kate \U0001f4ab', u'created_at': u'Tue Feb 14 20:23:54 +0000 2012', u'time_zone': u'Mountain Time (US & Canada)', u'profile_sidebar_border_color': u'DFDFDF', u'listed_count': 55}}
{u'lang':u'en',u'full_text':你有没有遇到过如此多的麻烦,以至于你把你的选择缩小到a.中奖b.把你的车绕在电线杆上,c.给这个令人毛骨悚然的邻居百万富翁一个他一直在芝士蛋糕工厂纠缠的日子?\nPffffffttt.我也是[{u'扩展的url':u'https://twitter.com/_jkate/status/984219542061703168/photo/1“,u'h':{u'h':{u'h':1280,u'w':719,u'resize':u'fit'},u'small':{u'h':680,u'w':382,u'resize':u'fit'},u'Middle':{u'h':1200,u'w':674,u'resize':u'fit'},u'thumb':{u'h':150,u'w':u'resize crop'},u'url':u',u'media\u url\u https':u'https://pbs.twimg.com/media/Daimc02VQAAulWe.jpg'u'display_url':u'pic.twitter.com/ZfCeeZN4g0',u'type':u'photo',u'id':984219532733530112,u'media_url':u'http://pbs.twimg.com/media/Daimc02VQAAulWe.jpg“}”,u'created_at':u'Wed Apr 11 23:59:59+0000 2018',u'hashtags':[],u'user_notes':[],u'source':u'',u'id_str':u'984219542061703168',u'url':[],u'retweet_count':2,u'id':984219542061703168,u'favorite_count':83,u'user':{u'profile_use_background_image':True,u'id':492519212,u'profile_image_url_https':u