繁体   English   中英

在 tweepy Streaming 中提取推文时在末尾排除链接

[英]Excluding link at the end while pulling tweets in tweepy Streaming

我正在使用 tweepy 流来提取textextended_text text ,但是当我提取这些推文时,最后总是有一个 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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM