I created a small script to download all pictures of an Instagram user without using APIs as APIs poses few limitations like rate limit.
After few rounds of tweaking, optimisation and beautifying code, I though of creating a python package out of it. If you want to know how to create a distributable python package, this article will be extremely helpful as steps are discussed in great detail.
You can find the py_instagram_dl package listed on pypi.
link is - https://pypi.python.org/pypi/py-instagram-dl.
Create a virtual environment. Optional but strongly recommended. You may follow this simple and step by step pocket guide on Python Virtual Environment.
pip install beautifulsoup4 bs4 lxml requests urllib3
Now install this package.
pip install py_instagram_dl
Use the installed package in your code.
import py_instagram_dl as pyigdl import sys # run script by providing username as command line argument # usage : python script_name.py username try: pyigdl.download(sys.argv, wait_between_requests=1) except Exception as e: print(e)
Downloadmethod have one mandatory and two optional parameters as of now.
Valid username of Instagram user.
Default value - True (boolean).
Decides whether information should be printed on screen. Recommended to have it set to True so that in case of large number of downloads you can make sure script is working and is not just freezed.
Default value - 0 (integer).
This is the time in seconds for which scripts waits to send new hit to download the picture to Instagram. It is recommended to pass a positive value for this parameter. If you are getting rate limit exceptions after downloading few pictures, pass 1 in this parameter, i.e. wait for 1 second between each request.
When rate limit is reached. Use parameter
wait_between_requests to avoid this.
Source Code: Source code is available on Github.