Book Image

Mastering Social Media Mining with Python

By : Marco Bonzanini
Book Image

Mastering Social Media Mining with Python

By: Marco Bonzanini

Overview of this book

Your social media is filled with a wealth of hidden data – unlock it with the power of Python. Transform your understanding of your clients and customers when you use Python to solve the problems of understanding consumer behavior and turning raw data into actionable customer insights. This book will help you acquire and analyze data from leading social media sites. It will show you how to employ scientific Python tools to mine popular social websites such as Facebook, Twitter, Quora, and more. Explore the Python libraries used for social media mining, and get the tips, tricks, and insider insight you need to make the most of them. Discover how to develop data mining tools that use a social media API, and how to create your own data analysis projects using Python for clear insight from your social data.
Table of Contents (10 chapters)

Notes and activities from a Google+ page

After searching for a Google+ page and visualizing the results in a web GUI, we will proceed to download a list of activities for a given page. Activities are the Google+ equivalent of Facebook posts. By default, an activity is considered to be a note, that is, a piece of text shared on Google+.

The following script,, is used to collect a list of activities from a Google+ page:

# Chap05/ 
import os 
import json 
from argparse import ArgumentParser 
from apiclient.discovery import build 
def get_parser(): 
  parser = ArgumentParser() 
  parser.add_argument('--max-results', type=int, default=100) 
  return parser 
if __name__ == '__main__': 
  api_key = os.environ.get('GOOGLE_API_KEY') 
  parser = get_parser() 
  args = parser.parse_args() 
  service = build('plus', 
  activity_feed = service...