Giter Club home page Giter Club logo

twcloud's Introduction

twcloud

Generate a word cloud of Twitter tweets with a single command.

twcloud is a Python package that leverages the twint package to gather Tweets from any public account without requiring authentication, and the stylecloud package which adds many useful features to create truly unique word clouds!

  • Retrieve tweets from a user, or a Twitter search.
  • Gather any number of Tweets from the specified query for building the word cloud (even beyond the typical 3,200 limit)
  • Command Line Interface!

Additionally, from the base stylecloud package:

  • Icon shapes (of any size!) for word clouds
  • Support for advanced color palettes (via palettable)
  • Manual color selection for text and backgrounds,
  • Directional gradients w/ the aforementioned palettes.

Installation

You can install twcloud via pip:

pip3 install twcloud

Usage

You can use twcloud in a Python script or as a standalone CLI app. For example, let's visualize Twitter CEO Jack Dorsey's most recent Tweets:

From Python:

import twcloud

twcloud.gen_twcloud(username='jack')

Or from the command line:

twcloud --username jack

Or even more simply, to quickly gather tweets from a user:

twcloud jack

You can also search for keywords. How about finding English Tweets about #MondayNightFootball, and changing the theming appropriately?

import twcloud

twcloud.gen_twcloud(search='#MondayNightFootball lang:en',
                    icon_name='fas fa-football-ball',
                    background_color='black',
                    colors='yellow')
twcloud --search '#MondayNightFootball lang:en' --icon_name 'fas fa-football-ball' --background_color black --colors yellow

A little known feature of Twitter search is that if you search for a Tweet URL, you will get all Quote Tweets corresponding to that tweet. How about getting English quote tweets resulting from the recent tweet asking for quote tweets with controversial food opinions?

import twcloud

twcloud.gen_twcloud(search='https://twitter.com/jonbecker_/status/1196805486907052033 lang:en',
                    icon_name='fas fa-utensils',
                    background_color='#c0392b',
                    palette='colorbrewer.sequential.YlOrBr_3',
                    gradient='vertical')
twcloud --search 'https://twitter.com/jonbecker_/status/1196805486907052033 lang:en' --icon_name 'fas fa-utensils' --background_color '#c0392b' --palette colorbrewer.sequential.YlOrBr_3 --gradient vertical

Helpful Parameters

These parameters are valid for both the Python function and the CLI (you can use twcloud -- --help to get this information as well). Additional visual customization parameters can be found within the stylecloud repo.

  • username: Twitter @ username to gather tweets (excluding the @). Any public Twitter account is valid.
  • search: Search query to use. Can use a hashtag or a tweet URL (to get quote-tweets)
  • limit: Number of tweets to gather before rendering the twcloud [default: 500]

stylecloud parameters w/ Changed Defaults

  • icon_name: Icon Name for the stylecloud shape. (e.g. 'fas fa-grin') [default: fab fa-twitter]
  • colors: Color(s) to use as the text colors. [default: white]
  • background_color: Background color (name or hex) [default: #1DA1F2]
  • output_name: Output file name of the stylecloud. [default: twcloud.png]

Helpful Notes

  • Specifying a palette parameter will override the colors parameter. This is the reverse of stylecloud.
  • Saving the retrieved tweets is out of scope for this package. If you want to save the tweets + additional metadata, use twint directly.
  • username queries will not return Retweets made by the user.
  • Advanced search filters can be useful too for increasing the quality of the twcloud, e.g. filter:verified to retrieve only tweets from verified users, or lang:en to retrieve only English tweets.

Maintainer/Creator

Max Woolf (@minimaxir)

Max's open-source projects are supported by his Patreon and GitHub Sponsors. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT

Disclaimer

This repo has no affiliation with Twitter Inc.

twcloud's People

Contributors

minimaxir avatar

Stargazers

 avatar  avatar Michael Joseph avatar Shantanu Oak avatar Kaito Sugimoto avatar Prateek Ralhan avatar glaringgibbon avatar ihsan avatar  avatar Nour Haridy avatar Rodolfo Pardo avatar tg-z avatar  avatar Rahul Bhaskar avatar  avatar YOLO avatar Allen avatar Bob Blanchett avatar 夜轮_NachtgeistW avatar Kim avatar Dev avatar 爱可可-爱生活 avatar CeShine Lee avatar Magicsword avatar Alex Kagai avatar Erdi Mollahüseyinoğlu avatar Sevda Anefi avatar Javier Estraviz avatar . avatar JN avatar Hernan Galante avatar Rodolfo Ferro avatar Mauricio Uribe avatar  avatar Berkay avatar Chris Hills avatar  avatar Mohan Balachandran avatar Rob Moore avatar chris willis avatar Zack Bunch  avatar Adam avatar Michael Pangburn avatar Ibrahim Sharaf avatar  avatar Alex Popescu avatar  avatar Sebastian Rama avatar Gerardo Lopez Santibañez avatar Haroldo de Oliveira Pinheiro avatar Mohammad Reza Taesiri avatar Rakuraku Jyo avatar Spiros Gerokostas avatar Leechael avatar Levente Vig avatar Guillaume Dumoulin avatar Michal Zygar avatar err avatar Amolo avatar Julian avatar Heyward Fann avatar Mattt avatar Sawit Trisirisatayawong avatar Shashi avatar Igor Zubkov avatar Jonathan Wong avatar Apurv Mishra avatar Jonathan Fly avatar Rohit Kumar Singh avatar  avatar Anne L'Hôte avatar James LeDoux avatar Alexandru Dan avatar John avatar Pratyk avatar

Watchers

James Cloos avatar  avatar Chagge avatar  avatar

twcloud's Issues

Handle smart quotes better

This approach takes a pessimistic approach (remove all contractions) which will work in most cases but there are occasionally false positives (e.g. she'll becomes shell).

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.