Skip to content

Instantly share code, notes, and snippets.

@avuko
Created May 30, 2017 20:20
Show Gist options
  • Save avuko/98da6e98b00ec029025aaf394fccdc6e to your computer and use it in GitHub Desktop.
Save avuko/98da6e98b00ec029025aaf394fccdc6e to your computer and use it in GitHub Desktop.
Simple tool to monitor the number of followers of RealDonaldTrump
#!/usr/bin/env python
import requests
import datetime
import pytz
from bs4 import BeautifulSoup
import time
import sys
while True:
r = requests.get('https://twitter.com/realdonaldtrump')
broth = r.content
soup = BeautifulSoup(broth, "html.parser")
spoon = soup.find_all("a", {"data-nav": "followers"})
balls = BeautifulSoup(str(spoon[0]), "html.parser")
grease = balls.find("span", {"class": "ProfileNav-value"})
dinnersready = datetime.datetime.now(pytz.timezone("America/New_York"))
cookingtime = dinnersready.replace(microsecond=0).isoformat()
sys.stdout.write(cookingtime + " - @realDonaldTrump followers: " + grease.text + "\n")
sys.stdout.flush()
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment