Code Monkey home page Code Monkey logo

shutdownstem's Introduction

shutdownstem

twitter analysis of #shutdownstem

Setup

This code requires Python 3.7. In a virtualenv:

pip install -r requirements.txt
export TWITTER_SCRAPE_ACCESS_KEY=yoursecrethere
export TWITTER_SCRAPE_ACCESS_SECRET=yoursecrethere
export TWITTER_SCRAPE_CONSUMER_SECRET=yoursecrethere
export TWITTER_SCRAPE_CONSUMER_KEY=yoursecrethere

Run

To scrape all tweets from the last 7 days associated with the #shutdownstem hashtag:

$ ./scrape.py
[*] starting at 1592161515.267193
[*] scraping #shutdownstem
[*] got 100 tweets so far...
[*] got 200 tweets so far...
[*] got 300 tweets so far...
[*] got 400 tweets so far...
...
[*] got 83900 tweets so far...
[*] tweets saved to 20200614-135000.csv
[*] raw tweets serialized to 20200614-135000.pkl

The CSV and pickle files will contain the scraped tweets.

Further analysis

With the CSV file (not committed) one can do further analysis via:

>>> import pandas as pd
>>> df = pd.read_csv('20200614-135000.csv')
>>> df.head()
         authors                                               text  is_rt
0    Dudeminator  RT @BretWeinstein: I like horses but dislike T...   True
1  signed_coward  RT @yasemete: 性善説というよりは、知識のない人は簡単にデモ隊や暴徒になりますか...   True
2  signed_coward  RT @yasemete: 科学誌ネイチャーが #ブラックライブズマター への支援で #sh...   True
3     metaverity  RT @Sandra_Phoma: Cite black scientists. Invit...   True
4      kainoeske  RT @claudiascosmos: I am not an academic but I...   True
>>> len(df)
83931

Scraping a different hashtag

If you'd like to scrape a different hashtag there is an optional arg for that, please provide the hashtag without the hash:

./scrape.py MyHashtagWithoutTheHash

shutdownstem's People

Watchers

 avatar  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.