[PYTHON] I tried to make a system that fetches only deleted tweets

what's this?

A program that uses Tweepy in Python to monitor the timeline and output only deleted tweets as standard output.

Source

-Twitter agrees to revive the tweet archive site "Politwoops" deleted by politicians -Politwoops (Archive site for tweets deleted by politicians)

code

I'm using Tweepy with Python3. You can install it by doing `` `pip install tweepy```. Please enter the one you prepared for CONSUMER_KEY.

delcheck.py



# coding: UTF-8
import tweepy
from datetime import timedelta
import json

CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_TOKEN = ""
ACCESS_TOKEN_SECRET = ""

my_db = {}

def get_oauth():
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
    return auth

def pprint(dict_data):
    for k, v in dict_data.items():
        print(k, v)

class Listener(tweepy.StreamListener):
    def on_error(self, status_code):
        print("Error: " + str(status_code))

    def on_data(self, data):
        obj = json.loads(data, encoding="UTF-8")
        if "delete" in obj:
            tweet_id = obj.get("delete").get("status").get("id")
            print("deleted!")

            if tweet_id in my_db:
                print(my_db[tweet_id])
            else:
                print("-")

        elif "text" in obj:
            my_db[obj.get("id")] = obj.get("user").get("screen_name") + ": " + obj.get("text")

    def on_timeout(self):
        print("Timeout...")

if __name__ == "__main__":
    auth = get_oauth()
    listener = Listener()
    stream = tweepy.Stream(auth, listener)
    stream.userstream()

Serpentine

Notifications such as deletion will be sent to on_data. The data of the user's timeline is saved from the time of startup, and if there is something saved in the deleted one, it will be output as standard. Using a proper DB Instead, I save the data from the timeline (tweet body only) in my_db (dictionary type object).

What I noticed after moving it for a day was that everyone deleted the tweets.

Postscript (October 24, 2017)

A service like this violates Twitter's terms. Note that a similar service has been angry and erased from Twitter.

Promotion

Follow us: alien: @redshoga

Recommended Posts

I tried to make a system that fetches only deleted tweets
I tried to make a Web API
I tried to make a bot that randomly acquires Wikipedia articles and tweets once a day
I tried to make a ○ ✕ game using TensorFlow
I tried to make a skill that Alexa will return as cold
I tried to make a "fucking big literary converter"
I tried to create a table only with Django
I tried to implement a recommendation system (content-based filtering)
[Python] I tried to make a Shiritori AI that enhances vocabulary through battles
I tried to make a translation BOT that works on Discord using googletrans
I tried to make a dictionary function that does not distinguish between cases
[LPIC 101] I tried to summarize the command options that are easy to make a mistake
[Python + Bottle] I tried to release a web service that visualizes Twitter's positioned tweets.
I tried to make a memo app that can be pomodoro, but a reflection record
I tried to make a stopwatch using tkinter in python
I tried to make a simple text editor using PyQt
[1 hour challenge] I tried to make a fortune-telling site that is too suitable with Python
I tried to make a generator that generates a C # container class from CSV with Python
[5th] I tried to make a certain authenticator-like tool with python
I tried to create a server environment that runs on Windows 10
I tried to make an activity that collectively sets location information
[2nd] I tried to make a certain authenticator-like tool with python
I tried to make a regular expression of "amount" using Python
[Python] I tried to implement stable sorting, so make a note
I tried to make a regular expression of "time" using Python
[3rd] I tried to make a certain authenticator-like tool with python
[Python] A memo that I tried to get started with asyncio
I tried to make a regular expression of "date" using Python
I tried to make a periodical process with Selenium and Python
I tried to make a 2channel post notification application with Python
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python
[1st] I tried to make a certain authenticator-like tool with python
I tried to make a strange quote for Jojo with LSTM
I tried to make a mechanism of exclusive control with Go
I tried to create a linebot (implementation)
I tried to make a site that makes it easy to see the update information of Azure
I tried to create a linebot (preparation)
[Python] I tried to make a simple program that works on the command line using argparse.
I tried to make a script that traces the tweets of a specific user on Twitter and saves the posted image at once
Python: I tried to make a flat / flat_map just right with a generator
I tried to implement deep learning that is not deep with only NumPy
I tried to implement a blockchain that actually works with about 170 lines
I tried to make a face diagnosis AI for a female professional golfer ①
I tried to make a face diagnosis AI for a female professional golfer ②
I tried to make a calculator with Tkinter so I will write it
I tried to make "Sakurai-san" a LINE BOT with API Gateway + Lambda
I tried to draw a system configuration diagram with Diagrams on Docker
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I tried to develop a Formatter that outputs Python logs in JSON
I tried to make a url shortening service serverless with AWS CDK
I tried to make a system to automatically acquire the program guide → register it in the calendar in one day
I want to make matplotlib a dark theme
How to make a dialogue system dedicated to beginners
I tried to build a super-resolution method / ESPCN
A memorandum to make WebDAV only with nginx
I tried to build a super-resolution method / SRCNN ①
I want to make a game with Python
I tried to make AI for Smash Bros.
I read "How to make a hacking lab"
I tried to generate a random character string