Python 3 Web Scraping Script to Get Twitter Followers of Username Using BeautifulSoup4 Library on Command Line

There is a lot of confusion Python 3 Web Scraping Script to Get Twitter Followers of Username Using BeautifulSoup4 Library on Command Line We are sure this article will give you a clear result. Let’s go into the article.

Python 3 Web Scraping Script to Get Twitter Followers of Username Using BeautifulSoup4 Library on Command Line

Python 3 Web Scraping Script to Get Twitter Followers of Username Using BeautifulSoup4 Library on Command Line

from bs4 import BeautifulSoup
import requests
handle = input('Input your account name on Twitter: ')
temp = requests.get('https://twitter.com/'+handle)
bs = BeautifulSoup(temp.text,'lxml')
try:
    follow_box = bs.find('li',{'class':'ProfileNav-item ProfileNav-item--followers'})
    followers = follow_box.find('a').find('span',{'class':'ProfileNav-value'})
    print("Number of followers: {} ".format(followers.get('data-count')))
except:
    print('Account name not found...')

Final Words

We hope the Python 3 Web Scraping Script to Get Twitter Followers of Username Using BeautifulSoup4 Library on Command Line article has given good results for your confusion. See you in the next article.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment