Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在tweepy流媒体中拉推tweets时排除末尾的链接_Python_Api_Twitter_Streaming_Tweepy - Fatal编程技术网

Python 在tweepy流媒体中拉推tweets时排除末尾的链接

Python 在tweepy流媒体中拉推tweets时排除末尾的链接,python,api,twitter,streaming,tweepy,Python,Api,Twitter,Streaming,Tweepy,我正在使用tweepy流媒体拉取文本或扩展文本,但当我拉取这些推文时,最后总是有一个t.co/randomletters链接,没有任何结果。它是什么?我该如何摆脱它? 以下是一个例子: "text": "To make room for more expression, we will now count all emojis as equal—including those with gender‍‍‍ ‍‍and skin tone modifiers htt

我正在使用tweepy流媒体拉取
文本
扩展文本
,但当我拉取这些推文时,最后总是有一个t.co/randomletters链接,没有任何结果。它是什么?我该如何摆脱它? 以下是一个例子:

 "text": "To make room for more expression, we will now count all emojis as equal—including those with gender‍‍‍ ‍‍and skin tone modifiers https://t.co(forward slash)MkGjXf9aXm"

请帮助

根据我对twitter和tweepy的经验,只要在实际推文中有某种URL,这些URL就会包含在推文文本中,因此我们无法真正避免得到它们

您可以在获取它们之后删除它们,这是一个简单的正则表达式,它用一个空白字符串替换这些URL的模式

import re

re.sub(r' https://t.co/\w{10}', '', tweet_text)

哦,对了-当推特中有视频或照片时,它是否也包含url?是的,如果真的有纯文本以外的内容,您将在API响应中获得此表单的url。