Vipul Gupta
Vipul is a software engineer at balena and a documentarian running his docs initiative called Mixster. He advocates strongly for open-source, cheesecakes and party parrots.
Available all over the web by vipulgupta2048
Student, Programmer, Writer, Open-Source Contributor,
Traveller, C&H Comics Collector
Tweet @vipulgupta2048
Resembling a mountain bluebird with a dash of hummingbird thrown in, the Twitter bird has a beak and body that point toward the sky in what Bowman called “the ultimate representation of freedom, hope, and limitless possibility.”
Written in Java, Ruby, Scala, JavaScript
Serving 350 million users
Twitter dislikes spiders
Go to - https://apps.twitter.com
Installing Tweepy
# Install Tweepy for Python
pip install tweepy
# Download Scripts from Vanilla Repository
wget https://github.com/vipulgupta2048/vanilla/raw/master/vanilla_bot/config.py
wget https://github.com/vipulgupta2048/vanilla/raw/master/vanilla_bot/vanilla.py
Check out - https://github.com/vipulgupta2048/vanilla/
# Connecting/Authenticating our module with Twitter API
AUTH = tweepy.OAuthHandler(consumer_key, consumer_secret)
AUTH.set_access_token(access_token, access_token_secret)
API = tweepy.API(AUTH)
# Get access token
auth.get_access_token("verifier_value")
'''Doesn't get easier than this'''
for follower in tweepy.Cursor(api.followers).items():
follower.follow()
This snippet will follow every follower of the authenticated user.
for follower in tweepy.Cursor(api.followers).items():
follower.follow()
This snippet will follow every follower of the authenticated user.
Limiting requests - #Respectthemaintainer
import time
.
..
.
for tweet in tweepy.Cursor(API.search, q=searchterm):
tweet.retweet()
# limiting the number of requests sent
time.sleep(15)
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
time.sleep(15 * 60)
for follower in limit_handled(tweepy.Cursor(api.followers).items()):
if follower.friends_count < 300:
print follower.screen_name
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
time.sleep(15 * 60)
for follower in limit_handled(tweepy.Cursor(api.followers).items()):
if follower.friends_count < 300:
print follower.screen_name
# Only iterate through the first 200 statuses
for status in tweepy.Cursor(api.user_timeline).items(200):
process_status(status)
# Only iterate through the first 3 pages
for page in tweepy.Cursor(api.user_timeline).pages(3):
process_page(page)
The world is your oyster and the only thing that limits you is what you can see and imagine.
- Vipul Gupta
See what you like in other bots.
Keep what works, throw out what doesn't.
A bot is only as ethical as the person who programs it.
Questions? Any feedback
Did you like the talk? tweet about it. Retweets guaranteed !!
Vipul Gupta
Student, Programmer, Writer, Open-Source Contributor, Traveller, C&H Comics Collector
Tweet @vipulgupta2048
By Vipul Gupta
The zero to hero guide of making twitter bots using the Python Programming Language.
Vipul is a software engineer at balena and a documentarian running his docs initiative called Mixster. He advocates strongly for open-source, cheesecakes and party parrots.