In this article, I’ll walk you through scraping Twitter with Python without API using the twint module, and I’ll also analyze some relationships based on followings and mentions among a group of Twitter users.

One of the hot topics in data science is social media analytics. People love these analyzes and interest them because everyone knows this world. Most of our time is spent on Twitter, Instagram, Facebook, and some other social media apps. The use of social media analysis is mostly used in the tasks of relationship analysis. With not only scraping twitter with python, but I will also do some relationship analysis based on our scrapped data.

**Scraping Twitter with Python **

Now, let’s start with our task. In this task of scraping twitter with python, we need to install a package known as twint, which can be easily installed by using the pip command in your terminal – pip install twint. If you have installed this library, let’s import the necessary packages and get started with the task of scraping twitter with python:

import twint
import pandas as pd
from collections import Counter

After importing the necessary libraries, now we need to start by creating a user list consisting of Twitter accounts. We will analyze the relationships between the Twitter accounts of these people that I will add in the list below:

users = [
    'shakira',
    'KimKardashian',
    'rihanna',
    'jtimberlake',
    'KingJames',
    'neymarjr',
]

I’ve chosen popular Twitter users that everyone knows to make our analysis more interesting.

Scraping Twitter with Python and Analyzing Relationships

Now let’s start by scraping Twitter with python and to analyze the relationships between all the Twitter accounts in our list above, I’ll write a function named get_followings which will send a request to the twint library with a username. This function will return a list of users that our input user follows

#machine learning #python #data science

Scraping Twitter with Python | Data Science | Machine Learning | Python
2.10 GEEK