Skip to content

Python scripts for scraping the Twitter API and carrying out network and sentiment analysis

Notifications You must be signed in to change notification settings

norrishd/TwitterAnalysis

Repository files navigation

TwitterAnalysis

David Norrish Nov-Dec 2017

Scripts for calling the Twitter API to retrieve relevant tweets, then carry out network, sentiment and NLP analysis.

  1. Retrieve some tweet data using twitter_search.py
  2. Network analysis with network_analysis.py

Uses the Python Twitter Tools package and Twitter API: https://pypi.python.org/pypi/twitter

Getting Tweet data

twitter_search.py takes a search query, optional additional arguments, and retrieves relevant tweets using the Twitter Search API. Note the API rate limits and search functionality query protocols.

Optional arguments include:

  • count: # of tweets to retrieve (default = 15, max 100 per API call, but multiple calls will automatically be strung together if needed)
  • lang (str): A valid ISO 639-1 code, e.g. 'en'
  • result_type: whether to retrieve recent or popular tweets, or a mix (default)
  • exact: only retrieve exact phrase matches

More information about Twitter search parameters available here

Network analysis

Sentiment analysis

About

Python scripts for scraping the Twitter API and carrying out network and sentiment analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published