在 tweepy Streaming 中拉推文时在最后排除 link
Excluding link at the end while pulling tweets in tweepy Streaming
我正在使用 tweepy 流式传输 text
或 extended_text
,但是当我拉取这些推文时,最后总是有一个 t.co/randomletters link导致无处可去。它是什么以及如何摆脱它?
这是一个例子:
"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)
我正在使用 tweepy 流式传输 text
或 extended_text
,但是当我拉取这些推文时,最后总是有一个 t.co/randomletters link导致无处可去。它是什么以及如何摆脱它?
这是一个例子:
"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)