批量删除推文
“He who controls the past controls the future. He who controls the present controls the past.” — George Orwell
“ 控制过去的人控制着未来 。 控制现在的人控制过去 。” —乔治·奥威尔
James Gunn was on top of the world. He’d just directed two of the best action-comedy movies of the past decade. Both of his Guardians of the Galaxy movies were well-received by critics and audiences alike.
詹姆斯·冈恩(James Gunn)在世界之巅。 他刚刚执导了过去十年中最好的两部喜剧喜剧电影。 他的《银河护卫队》电影都受到评论家和观众的一致好评。
But that wasn’t enough to save him from his past self.
但这还不足以使他脱离过去的自己。
It turns out that earlier in his career Gunn had tweeted some rather shocking “jokes” on Twitter. (I won’t share them here — you’re probably better off not reading them.)
事实证明,耿恩在职业生涯的早期曾在Twitter上发布过一些相当令人震惊的“笑话”。 (我不会在这里与他们分享-您最好不阅读它们。)
Back then, Gunn was an obscure budget horror movie maker. And the tweets in question lie dormant for years in his Twitter history, with nobody reading them or caring.
那时,Gunn是一位不起眼的预算恐怖片制作人。 而且相关的推文在他的Twitter历史上一直处于Hibernate状态,没有人阅读或关心它们。
That is, until a few reporters decided to dig up dirt on him, and unearthed the tweets for all the world to see.
就是说,直到一些记者决定挖他身上的污垢,并发掘了全世界的推文。
His bosses at Disney immediately decided to “sever their business relationship” with Gunn.
他在迪士尼的老板们立即决定与Gunn“断绝业务关系”。
So within the span of a few hours, Gunn went from star director to Hollywood pariah. All because of a few tweets from 2012.
因此,在短短的几个小时内,耿恩就从明星导演转到了好莱坞贱民。 都是由于2012年的几条推文。
控制你的过去 (Control your past)
In this tutorial, I’m going to show you how you can download all your old tweets from Twitter, then quickly delete as many of those tweets as you want — all without sharing any of your data with anyone.
在本教程中,我将向您展示如何从Twitter下载所有旧的tweet,然后根据需要快速删除任意数量的tweet,而无需与任何人共享任何数据。
I did this myself a few minutes ago.
几分钟前我自己做了。
Sure, I like the idea of future historians scrutinizing my Tweets asking: “What was Quincy Larson really like?” But not as much as I dislike the idea of some hater digging through my Twitter feed and cherry picking a tweet where I sounded like a jerk.
当然,我喜欢未来的历史学家审查我的推文的想法,问:“昆西·拉尔森到底喜欢什么?” 但是我不喜欢这样的想法,我讨厌在我的Twitter提要中挖掘一些仇恨,并在我听起来像个混蛋的情况下挑选了一条推文。
There are a lot of services you can find that will delete your tweets for you if you give them access to your Twitter account (and maybe some money, too).
如果您允许他们访问自己的Twitter帐户(可能也有一些钱),可以找到很多服务,这些服务将为您删除推文。
I didn’t feel comfortable sharing access to my Twitter accounts with any of those services. In fact, creating such a “tweet deleting” service jumped out at me as a evil genius kind of thing to do. “Oh, you have something to hide, do you?”
通过这些服务中的任何一个共享对我的Twitter帐户的访问权,我感到不舒服。 实际上,创建这样的“ tweet删除”服务是一件令人讨厌的天才,使我无所适从。 “哦,你有东西要隐藏,对吗?”
But we can leave such dirty work to the digital paparazzi.
但是我们可以把这种肮脏的工作留给数字狗仔队。
Instead, this tutorial will show you how to delete all your tweets from before a certain date yourself — for free and in bulk — using a simple Python script.
取而代之的是,本教程将向您展示如何使用简单的Python脚本免费,免费地删除特定日期之前的所有推文。
It may feel like every tweet from your past is a special and unique snowflake. If you feel this way, you may want to instead manually go through your old tweets and just delete the old tweets that embarrass you.
您过去的每条推文都可能像雪花一样特殊。 如果您有这种感觉,您可能需要手动浏览旧的Tweet,然后删除使您感到尴尬的旧Tweet。
But if you have thousands of tweets like I do, that’s going to take you hours and hours.
但是,如果您像我一样拥有成千上万条推文,那将花费您数小时和数小时。
Note that deleting old tweets will not affect your Twitter followers at all, other than to remove some stuff they are frankly too busy to go back and ever read. (There are 350,000 new tweets created every minute on Twitter. Ain’t nobody got time for that!)
请注意,删除旧的推文根本不会影响您的Twitter关注者,除了删除一些坦率地说太忙而无法阅读的内容。 (Twitter上每分钟创建350,000条新推文。没有人有时间这样做!)
Let’s get started!
让我们开始吧!
步骤1:如何为所有推文创建个人备份 (Step 1: How to create a personal backup of all your tweets)
The first thing you need to do is create a backup of all your tweets. Twitter allows you to easily export all of your past tweets into a convenient CSV file.
您需要做的第一件事是创建所有推文的备份。 Twitter使您可以轻松地将所有过去的推文导出到方便的CSV文件中。
Navigate to Twitter’s “Your Twitter Data” section in their settings. Here’s a direct link.
在其设置中导航到Twitter的“您的Twitter数据”部分。 这是直接链接 。
Twitter will ask you to confirm your password. Then click “request data” at the bottom of the page.
Twitter会要求您确认密码。 然后,点击页面底部的“请求数据”。
Twitter emailed me a nice zip file within a few minutes.
Twitter在几分钟内给我发送了一个不错的zip文件。
If you think you’ll ever want to read the old tweets you’re about to delete, be sure to backup this zip file some safe.
如果您认为自己想阅读要删除的旧推文,请务必将这个zip文件备份一些安全。
Then unzip the folder. Here’s what the folder looks like:
然后解压缩该文件夹。 文件夹的外观如下:
You can open up index.html in a browser and you’ll see a nice user interface where you can scroll through your tweets by month and year.
您可以在浏览器中打开index.html,您会看到一个漂亮的用户界面,可以在其中按月份和年份滚动浏览推文。
Note that you’ll need the tweets.csv
file for the final step of this tutorial.
请注意,本教程的最后一步将需要tweets.csv
文件。
步骤2:安装Python库 (Step 2: Install the Python library)
For this step, I’m going to assume you’re using a MacOS. If someone wants to create a clear list of step-by-step Linux or Windows instructions for this step, share them in a comment below. I’ll add them here and credit you. ?
对于这一步,我将假设您正在使用MacOS。 如果有人想为此步骤创建清晰的Linux或Windows分步说明列表,请在下面的评论中分享。 我将其添加到此处并归功于您。 ?
Go into your command line and run this command to clone the repository:
进入命令行并运行以下命令来克隆存储库:
git clone git@github.com:QuincyLarson/delete-tweets.git
Go into the newly-created directory:
进入新创建的目录:
cd delete-tweets
Make sure you have PIP (a Python package manager) installed:
确保已安装PIP(Python程序包管理器):
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Now you can install all the library’s dependencies:
现在,您可以安装库的所有依赖项:
pip install -r requirements.txt
Note that you may have to run some of these commands with “sudo” at the beginning to get them work properly. And you may get some “can’t find xyz library” messages. I was able to ignore those messages and still get this to work.
请注意,您可能必须在开始时使用“ sudo”运行其中一些命令,以使其正常工作。 并且您可能会收到一些“找不到xyz库”消息。 我能够忽略这些消息,但仍然可以正常工作。
步骤3:建立Twitter API金钥 (Step 3: Create Twitter API keys)
Go to https://apps.twitter.com/app/new and fill out the form like so:
转到https://apps.twitter.com/app/new并按照以下方式填写表格:
You can put basically anything here — the only person who’s going to use this Twitter app is you.
您基本上可以在这里放任何东西-唯一要使用此Twitter应用程序的人是您。
Now in your newly created Twitter app, click “Keys and Access Tokens” and then at the bottom, click “Create my access token”.
现在,在您新创建的Twitter应用程序中,单击“密钥和访问令牌”,然后在底部单击“创建我的访问令牌”。
Now use your trusty text editor of choice and open up deletetweets.py.
现在,使用您选择的可信任文本编辑器并打开deletetweets.py.
Scroll down to line 54. You are going to manually copy/paste your keys over to here.
向下滚动到第54行。您将手动将密钥复制/粘贴到此处。
Save the file and exit.
保存文件并退出。
步骤4:将tweets.csv文件复制到 (Step 4: Copy your tweets.csv file over)
In step 1 you downloaded an personal backup of all your past tweets. Copy the tweets.csv
file from that folder over to your new delete-tweets folder. It will replace the placeholder tweets.csv file.
在第1步中,您下载了过去所有推文的个人备份。 将tweets.csv
文件从该文件夹复制到新的delete-tweets文件夹。 它将替换占位符tweets.csv文件。
步骤4:删除推文 (Step 4: Delete the tweets)
Now you just need to decide on a “cut-off date” — a date before which all of your tweets will be deleted.
现在,您只需要确定一个“截止日期”,即所有推文都将被删除的日期。
For example, if that date was October 1, 2013 then you’d use the following command in your terminal:
例如,如果该日期是2013年10月1日,那么您将在终端中使用以下命令:
python deletetweets.py -d 2013-10-01
The script will then start with that date and go in reverse chronological order, deleting one tweet each second until it’s done.
然后,脚本将从该日期开始,并按时间倒序排列,每秒删除一条推文,直到完成为止。
At the end, it will tell you how many tweets it deleted.
最后,它将告诉您删除了多少条推文。
Congratulations — you have controlled your past.
恭喜,您已经控制了自己的过去。
And now you have one less thing to worry about in the future.
现在,您将来无需担心的一件事。
Now close your terminal and get on with your life.
现在关闭终端,继续您的生活。
You should follow me on Twitter for practical tech stuff that’s worth your time.
您应该在Twitter上关注我,以获取有价值的实用技术。
批量删除推文