Welcome folks today in this post we will be scraping
instagram posts
and images without instagram api
in python using instagramy
library. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the following library using the pip
command as shown below
pip install instagramy
After installing this library make an app.py
file and copy paste the following code
Instagram User Details
First of all we will get the instagram user details in this python script
app.py
1 2 3 4 5 6 7 8 9 10 11 12 |
from instagramy import InstagramUser session_id = "38566737751%3Ah7JpgePGAoLxJe%334" # Connecting the profile user = InstagramUser('google', sessionid=session_id) # printing the basic details like # followers, following, bio print(user.is_verified) print(user.biography) |
Now if you execute the python
script by typing the below command
python app.py`
Now if you execute this script it will tell you the biography
and verified
status of the user as shown below
Instagram HashTags Details
Now we will be writing the python script to scrape instagram
hashtag details
app.py
1 2 3 4 5 6 7 8 9 |
from instagramy import InstagramHashTag session_id = "38566737751%3Ah7JpgePGAoLxJe%334" # Connecting the profile posts = InstagramHashTag('coding', sessionid=session_id) print(posts.number_of_posts) |
It will tell you the number of posts
related to this hashtag
Instagram Posts Details
Now we will be scraping
the details of the instagram post such as the author
of post and likes
of post and also some more details
about the post such as images
and videos
1 2 3 4 5 6 7 8 9 10 11 |
from instagramy import InstagramPost session_id = "38566737751%3Ah7JpgePGAoLxJe%334" post = InstagramPost('CLGkNCoJkcM', sessionid=session_id) print(post.author) print(post.number_of_likes) print(post.post_data) # More data about post as dict |