Python 在tweepy流媒体中拉推tweets时排除末尾的链接
我正在使用tweepy流媒体拉取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
文本
或扩展文本
,但当我拉取这些推文时,最后总是有一个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。