baby Yoda's demand has been increasing
last time he asked me to write
bitcoin mining code in 15 lines of
Python
today's latest demand is to write
automating Instagram in Python in less
than 10
lines of code so in this video we will
be
uploading an image following someone
getting a list of followers in Instagram
using Python so this is Instagram
automation using Python let's get
started
i'm super active on Instagram you see
that I have three post and 66
followers so i'm going to automate this
particular account using Python
I open here Pycharm which is
a free editor for Python you need to
also
download the Python okay so you install
Python on your computer
and after you do that, go to Google and
type in
Python Insta board so python Instaboard
is the module we are going to use to
interact with Instagram
and if you open that link you will get
this command to install it so just copy
this
pip install Insta board and
copy paste this command, and it's going
to install it. I have already installed
it so it will say
it's already installed doesn't matter
now it is installed
so i will start writing code. Now, before
I do that
here on this page they have given
examples. So if you open the example
links you will find
many examples you can do so many things
I'm just going to show you some basic
stuff
so now let's move on to my
Instagram and here I'm going to increase
the font size
and also I am going to go into
my Zen mode you know I want to
meditate here is how I meditate
so first install or import actually
from Insta bot import board
so this is type of a bot that is
interacting with
Instagram okay and i will create an
instant of
a bot here and I will say bot dot
login
and here just specify your username and
password. So my username is
so just specify that as an
argument
and the first thing i'm going to do is
what do you do usually with Instagram
we'll upload pictures
yes, so bot dot upload
photo and here you will specify the
photo so in my folder here
I have a cute biscuit eating Yoda
so I will upload that okay so yoda.jpg
yoda.jpg
and you can specify caption here
cute biscuit
eating Yoda
okay? well
let's run this code and see what happens
so right click
run. So it is
trying to log in here so it will take
some time few seconds
it will log in and after it's logged in
it will just
upload. See this is probably the image
dimension
and it will try to upload it take some
time but finally the photo is uploaded
let me go back
to my profile and check what happened so
here's my profile
refresh my picture is uploaded cute
biscuit eating Yoda all right
so this is how you upload a picture now
I am following
only one person so I want to follow
let's say whom I want to follow
well maybe Elon Musk. you know, I want to
know when he's sending
humans to Mars so Elon R Musk
okay so let me follow him
and it's pretty easy see that's a
cool thing with Python you write
just one line of code you just say bo bo
dot
follow whom do you want to follow Elon
R Musk okay
I'll just remove this code okay so now I
want to follow Mr
Elon Musk so just run the
command again few seconds wait
let's see
Hooray I'm following Elon R Musk so if
you have
let's say 20 celebrities you want to
follow and you are
you don't want to do all the hard work
to type in their name and click on
the following button then just write a
Python code for it
super easy. how do I send messages by the
way to
people. So I have
So I have let's see I have this
followers people you know okay
mr smart 1k is my buddy Mr Smart 1k I'm
going to send you a message using python
and I will also send a message to my
other profile which is by
the way code basics hub
so Instagram so if you look at
CodeBasics up this is the profile for
my channel
so I will send a message to this
as well so I will just say bot
don't send a message see it's so English
like send a message
send a message hi from
baby Yoda you can see how obsessed I am
with
baby Yoda so Mr Smart 1k
is one account and then code basics
hub is the another account and just run
it
and it's gonna send a message to them
okay looks like it sent a message
let me check it out so I go here
I go to not now you see
you see it's handed it's real it works
hi from baby Yoda I see two people
you want to send a group message to 10
people yeah sure Python code
see python is so powerful I want to get
a list of
all my followers and print it here so
who are my followers well
so if you go to my profile again so this
I have 66 followers you see how famous I
am
and I want to print their name or
their tagline whatever
so again bot dot get
user followers so when you do user
followers by the way there is
get followers as well it will get you
the followers of the current profile
but if you do user followers it you can
type in name you know
so I have my account
name is Dhaval says if you do Elon R
Musk it will get you
all the followers of Mr Elon
okay so followers and I want to
see like who those followers are so what
I do
is usually okay now I need to come out
of my meditation so
exits and more and I need to put a break
point here
just to see you know what happens and
right click and debug so when you do
debug
I have this habit of doing debug so that
at least I know what kind
of object I am getting back and it's a
list
of strings so these are the ids
of those users okay so see 66 of them
and if you want to get their let's say
name so
I can say for follower in followers
okay follower in followers print
I can do both dot get
user info get user
info okay and
so you can get user info of these
followers and when I right click run it
it's gonna print a lot of stuff by the
way
you see just printing all this
so I stopped the execution but you see
username is too smart one
Zalak Chauhan Yogi whatever Vishal Patel
so you see all those guys here
so you see that profile pic you see
actually you see lot of useful
information
if it is your age and you want to retire
you can also say
board dot unfollow everyone. if you do
this
you're gonna fall unfollow every single
person in your profile
I hope you like this there are many
examples I just showed you
few important things but if you go to
this page i'm gonna link
this page in a video description below
you will find
so many examples you can do so many
things with Instagram
one caveat you need to remember is and
that's what is mentioned on this project
page
is... so see
right now the uses of this library may
harm your Instagram profile because of
the new script detect algorithm
whenever there is any bot or web
scraping software
the websites which is like Instagram or
Facebook they don't like
boats accessing the software they want
humans to use their platform
for that reason they deploy this script
detection algorithm so if you are using
this script
make sure you don't overuse it otherwise
it will affect your profile
and you have to be mindful about the
implications of using boards for
any software i have a complete playlist
of
these kind of cool apps which you can
write in 10, 20 lines of python code
check it out in the video description
below i have a video on how you can mine
bitcoin
only by writing 15 lines of code
and if you have any comments post in a
video comment below
he has come up with a new demand already
so you have to make a guess
on what the demand is and what you want
me to write
some cool stuff you want me to write in
python in very less lines of code
post that suggestion in video comment
below and I will try to make a video on
it
and make my little cute baby happy