Code Monkey home page Code Monkey logo

tweets_scrape's Introduction

tweets_scrape

An automatic tool to scrape tweets with images

Prerequisites

  • snscrape is a scraper for social networking services (SNS).
  • tweepy is a library of Python to access Twitter API (If you use Python 3.9 or higher, please install the developer version).
  • A twitter developer account alongwith the API credentials.
  • Rename the config_example.py file to config.py. In this file, you need to modify the hashtags and time period to what you want. Also, add your Twitter API credentials in this file.

Scripts

autocommand.py - This file is to get tweet URLs in a particular time period. It can generate the snscrape commands in seven-day period.

scrape_tweets.py - This file is to get the tweet data like media_url, text_data in the tweet, etc., from URLs we got from above and save them into a .csv file. This part needs Twitter API keys, so please put your own API keys in the config.py file.

image_extract.py - This file is to get the images from the media_url of each tweet.

Please execute these three scripts in order

preprocessing.ipynb - This jupyter file will generate a concatenated dataframe for all the tweets and images in the data folder. Please first rename the data folder in the form of data_{topic_name}, and you only need to modify the variables in the first cell. The concatenated dataframe has all the tweets information linked with image path for each image. It will be stored in the csv_data folder.

opencv_text_detector.py - Detector model to detect the presence of text in an image. Required by preprocessing.ipynb, and do not need to execute alone.

tweets_scrape's People

Contributors

monsterandy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.