2nd European Conference on Social Networks, June 14-17, 2016, Paris (http://eusn2016.sciencesconf.org/)

Workshop 11:

Mining (together with a bit of web scraping) of large social networks from Twitter using Python (and Ruby)

By Moses Boudourides (Moses.Boudourides@gmail.com) and Sergios Lenis (sergioslenis@gmail.com)

University of Patras, Greece

I. Installing/Importing Prerequisite Python Modules and Scripts

The following cell imports the prerequisite Python modules for this network to run

In [1]:
import pandas as pd
import json 
import os
import imp
from IPython.display import Image

First, one has to download the github directory https://github.com/mboudour/TwitterMining, where everything needed for this notebook to run is included.

In particular, one needs to have already installed all the modules imported in the script collect_tweets_notebook.py. Some of these modules can be installed and imported from the notebook as follows (without #):

In [2]:
# !pip install twitter
# import twitter

II. Creating a Twitter App and Obtaining OAuth Settings

Assuming that one already possesses a Twitter account, one needs to create app from http://twitter.com/apps/new by following the instuctions given in the screenshots that follow:

In [3]:
# The first time one accesses the page http://twitter.com/apps/new, one is requested to sign in.

Image("pngs/apptwitter_new.png")
Out[3]:
In [4]:
# First, one need to log in her Twitter account (assuming that one already possesses it).

Image("pngs/login_to_twitter.png")
Out[4]:
In [5]:
# First, one should create a new application (or use an App already created).

Image("pngs/create_app.png")
Out[5]:
In [6]:
# One always has the option to creat a new App (if needed).

Image("pngs/select_app.png")
Out[6]:
In [7]:
# After creating/accessing an App, one should click the link "Keys and Access Tokens."

Image("pngs/app_created.png")
Out[7]:
In [8]:
# Next, to access tokens, one should click "Token Actions > Create my access token."

Image("pngs/create_tokens_pass.png")
Out[8]: