Running on a Headless Browser
headless_browser parameter to run the bot via the CLI. Works great if running the scripts locally, or to deploy on a server. No GUI, less CPU intensive. Example
Warning: Some users discourage the use of this feature as Instagram could detect this headless mode!
If the web driver you're using doesn't support headless mode (or the headless mode becomes very detectable), you can use the
nogui parameter which displays the window out of view. Keep in mind, this parameter lacks support and ease of use, only supporting Linux based operating systems (or those that have Xvfb, Xephyr and Xvnc display software).
Bypass Suspicious Login Attempt
InstaPy detects automatically if the Security Code Challenge is active, if yes, it will ask you for the Security Code on the terminal.
The Security Code is send to your Email or SMS by Instagram, Email is the defaul option, but you can choose SMS also with:
Two Factor Authentication
InstaPy detects automatically if the account is protected with the Two Factor Authentication, if yes InstaPy user need to provide the Security codes in the session constructor; at least one code is required.
Security codes can be found in:
Use a proxy
You can use InstaPy behind a proxy by specifying server address, port and/or proxy authentication credentials. It works with and without
Simple proxy setup example:
Proxy setup with authentication example:
Running internet connection checks
InstaPy can perform a few checks online, including you connection and the availability of Instagram servers. These checks sometimes fail because Instapy uses third party services to perform these checks. If this should be the case. you can override these checks with this variable:
want_check_browser default is False, you can set it to True at session start. Recommend to do this if you want to add additional checks for the connection to the web and Instagram.
Running in threads
If you're running InstaPy in threads and get exception
ValueError: signal only works in main thread , you have to properly close the session.
There is two ways to do it:
Closing session in smart_run context:
Closing session with
Choose the browser version
If you have more than one Firefox version on your system or if you are using a portable version you can instruct InstaPy to use that version using the
browser_executable_path argument in the class initializer.
Specifying the Firefox executable path can also help you if you are getting the following error message:
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
Example on a Windows machine (with the right path also works on Linux and macOS)