You are previewing Mastering Social Media Mining with Python.
O'Reilly logo
Mastering Social Media Mining with Python

Book Description

Acquire and analyze data from all corners of the social web with Python

About This Book

  • Make sense of highly unstructured social media data with the help of the insightful use cases provided in this guide

  • Use this easy-to-follow, step-by-step guide to apply analytics to complicated and messy social data

  • This is your one-stop solution to fetching, storing, analyzing, and visualizing social media data

  • Who This Book Is For

    This book is for intermediate Python developers who want to engage with the use of public APIs to collect data from social media platforms and perform statistical analysis in order to produce useful insights from data. The book assumes a basic understanding of the Python Standard Library and provides practical examples to guide you toward the creation of your data analysis project based on social data.

    What You Will Learn

  • Interact with a social media platform via their public API with Python

  • Store social data in a convenient format for data analysis

  • Slice and dice social data using Python tools for data science

  • Apply text analytics techniques to understand what people are talking about on social media

  • Apply advanced statistical and analytical techniques to produce useful insights from data

  • Build beautiful visualizations with web technologies to explore data and present data products

  • In Detail

    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.

    Style and approach

    This practical, hands-on guide will help you learn everything you need to perform data mining for social media. Throughout the book, we take an example-oriented approach to use Python for data analysis and provide useful tips and tricks that you can use in day-to-day tasks.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Mastering Social Media Mining with Python
      1. Mastering Social Media Mining with Python
      2. Credits
      3. About the Author
      4. About the Reviewer
        1. eBooks, discount offers, and more
          1. Why subscribe?
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      7. 1. Social Media, Social Data, and Python
        1. Getting started
        2. Social media - challenges and opportunities
          1. Opportunities
          2. Challenges
          3. Social media mining techniques
        3. Python tools for data science
          1. Python development environment setup
            1. pip and virtualenv
            2. Conda, Anaconda, and Miniconda
          2. Efficient data analysis
          3. Machine learning
          4. Natural language processing
          5. Social network analysis
          6. Data visualization
        4. Processing data in Python
        5. Building complex data pipelines
        6. Summary
      8. 2. #MiningTwitter – Hashtags, Topics, and Time Series
        1. Getting started
        2. The Twitter API
          1. Rate limits
          2. Search versus Stream
        3. Collecting data from Twitter
          1. Getting tweets from the timeline
          2. The structure of a tweet
          3. Using the Streaming API
        4. Analyzing tweets - entity analysis
        5. Analyzing tweets - text analysis
        6. Analyzing tweets - time series analysis
        7. Summary
      9. 3. Users, Followers, and Communities on Twitter
        1. Users, friends, and followers
          1. Back to the Twitter API
          2. The structure of a user profile
          3. Downloading your friends' and followers' profiles
          4. Analysing your network
          5. Measuring influence and engagement
        2. Mining your followers
        3. Mining the conversation
        4. Plotting tweets on a map
          1. From tweets to GeoJSON
          2. Easy maps with Folium
        5. Summary
      10. 4. Posts, Pages, and User Interactions on Facebook
        1. The Facebook Graph API
          1. Registering your app
          2. Authentication and security
          3. Accessing the Facebook Graph API with Python
        2. Mining your posts
          1. The structure of a post
          2. Time frequency analysis
        3. Mining Facebook Pages
          1. Getting posts from a Page
            1. Facebook Reactions and the Graph API 2.6
          2. Measuring engagement
          3. Visualizing posts as a word cloud
        4. Summary
      11. 5. Topic Analysis on Google+
        1. Getting started with the Google+ API
          1. Searching on Google+
        2. Embedding the search results in a web GUI
          1. Decorators in Python
          2. Flask routes and templates
        3. Notes and activities from a Google+ page
        4. Text analysis and TF-IDF on notes
          1. Capturing phrases with n-grams
        5. Summary
      12. 6. Questions and Answers on Stack Exchange
        1. Questions and answers
        2. Getting started with the Stack Exchange API
          1. Searching for tagged questions
          2. Searching for a user
        3. Working with Stack Exchange data dumps
        4. Text classification for question tags
          1. Supervised learning and text classification
          2. Classification algorithms
            1. Naive Bayes
            2. k-Nearest Neighbor
            3. Support Vector Machines
          3. Evaluation
          4. Performing text classification on Stack Exchange data
          5. Embedding the classifier in a real-time application
        5. Summary
      13. 7. Blogs, RSS, Wikipedia, and Natural Language Processing
        1. Blogs and NLP
        2. Getting data from blogs and websites
          1. Using the API
          2. Using the Blogger API
          3. Parsing RSS and Atom feeds
          4. Getting data from Wikipedia
          5. A few words about web scraping
        3. NLP Basics
          1. Text preprocessing
            1. Sentence boundary detection
            2. Word tokenization
            3. Part-of-speech tagging
            4. Word normalization
              1. Case normalization
              2. Stemming
              3. Lemmatization
              4. Stop word removal
              5. Synonym mapping
          2. Information extraction
        4. Summary
      14. 8. Mining All the Data!
        1. Many social APIs
        2. Mining videos on YouTube
        3. Mining open source software on GitHub
        4. Mining local businesses on Yelp
        5. Building a custom Python client
          1. HTTP made simple
        6. Summary
      15. 9. Linked Data and the Semantic Web
        1. A Web of Data
          1. Semantic Web vocabulary
          2. Microformats
          3. Linked Data and Open Data
          4. Resource Description Framework
          5. JSON-LD
        2. Mining relations from DBpedia
        3. Mining geo coordinates
          1. Extracting geodata from Wikipedia
          2. Plotting geodata on Google Maps
        4. Summary