Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Social Media Mining with Python

You're reading from   Mastering Social Media Mining with Python Unearth deeper insight from your social media data with advanced Python techniques for acquisition and analysis

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781783552016
Length 338 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Bonzanini Marco Bonzanini
Author Profile Icon Marco Bonzanini
Marco Bonzanini
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Social Media, Social Data, and Python FREE CHAPTER 2. #MiningTwitter – Hashtags, Topics, and Time Series 3. Users, Followers, and Communities on Twitter 4. Posts, Pages, and User Interactions on Facebook 5. Topic Analysis on Google+ 6. Questions and Answers on Stack Exchange 7. Blogs, RSS, Wikipedia, and Natural Language Processing 8. Mining All the Data! 9. Linked Data and the Semantic Web

Mining your posts

After introducing the Python facebook-sdk with a simple example, we will start digging into the data mining opportunities. The first exercise is to download our own posts (that is, the posts published by the authenticated user).

The facebook_get_my_posts.py script connects to the Graph API and gets a list of posts published by the authenticated user me. The posts are saved in the my_posts.jsonl file using the JSON Lines format that we have already adopted in Chapter 2, #MiningTwitter - Hashtags, Topics, and Time Series, and Chapter 3, Users, Followers, and Communities on Twitter, (each line of the file is a JSON document):

# Chap04/facebook_get_my_posts.py 
import os 
import json 
import facebook 
import requests 
 
if __name__ == '__main__': 
  token = os.environ.get('FACEBOOK_TEMP_TOKEN') 
 
  graph = facebook.GraphAPI(token) 
  posts = graph.get_connections('me', 'posts') 
 
  while True:  # keep paginating 
    try: 
      with...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image