Instapy: Getting started

Created on 6 Apr 2017  路  23Comments  路  Source: timgrossmann/InstaPy

First, a big thanks for your efforts and for writing your media blog post!

Since I鈥檝e never worked with Python, I鈥檓 not really sure what is necessary to get started with InstaPy.

I cloned your repository to uberspace, modified quickstart.py according to my aims and executed via SSH python setup.py install. Do I need to do anything else/different? For me the script doesn鈥檛 seem to work since my following accounts stays the same.

Also, what would be needed to do when I alter settings in quickstart.py? Will InstaPy automatically run with the new settings or is there anything to do to restart InstaPy?

Thanks in advance!

Kind regards

Tibor

Most helpful comment

@timgrossmann yeah dude, it was that. Thanks.

All 23 comments

You should be fine just running python quickstart.py
Or creating your own python script and then running it.

Okay, Thanks!

I get the following response:

python quickstart.py
Traceback (most recent call last):
  File "quickstart.py", line 6, in <module>
    InstaPy(username='myusername', password='mypassword')\
  File "/var/www/virtual/myusername/instapy/InstaPy/instapy/instapy.py", line 34, in __init__
    self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
  File "/home/myusername/lib/python2.6/selenium-2.53.6-py2.6.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/home/myusername/lib/python2.6/selenium-2.53.6-py2.6.egg/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1238, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x24f6450>> ignored

Can I ignore this error or do I have to do anything?

I鈥檓 wondering if the scripts is running already since my following count stays the same.

My quickstart.py looks like this:

from instapy import InstaPy

#Write your automation here
#Stuck ? Look at the github page or the examples in the examples folder

InstaPy(username='myusername', password='mypassword')\
  .login()\
  .like_by_tags(['#vorarlberg', '#bodensee', '#austria', '#food', '#eat', '#meal'], amount=100) \
  .set_do_comment(True, percentage=10) \
  .set_comments(['Great!', 'Nice!', 'Like it!']) \
  .set_do_follow(enabled=True, percentage=10, times=2) \
  .end()

@tibor What OS are you using?

You need the latest Google Chrome installed and configure the Chromedriver as you need (update, downgrade, varies with you OS)

After installing Chrome, try to run the following commands (assuming that you're running it on Ubuntu)

sudo apt-get -y install python3-pip python3-dev build-essential libssl-dev libffi-dev xvfb
sudo pip3 install --upgrade pip

If the quickstart.py doesn't work, download the latest chromedriver (assuming that you're running it on any x64 linux), unzip and put it on the "assets" folder and give the right permissions (chmod +x / chmod 755)

For OSx you should be fine just installing Chrome and running quickstart.py.

Hi,

uberspace is using CentOS 6 (I鈥檓 not sure if x32 or x64 but I assume x64).

I uploaded the latest chromedriver but wasn鈥檛 able to get the script running:

  File "/var/www/virtual/myusername/instapy/InstaPy/instapy/instapy.py", line 34, in __init__
    self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
  File "/home/myusername/lib/python2.6/selenium-2.53.6-py2.6.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/home/myusername/lib/python2.6/selenium-2.53.6-py2.6.egg/selenium/webdriver/common/service.py", line 86, in start
    self.assert_process_still_running()
  File "/home/myusername/lib/python2.6/selenium-2.53.6-py2.6.egg/selenium/webdriver/common/service.py", line 99, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service ./assets/chromedriver unexpectedly exited. Status code was: 1

I guess I have to ask uberspace or do you have an idea how to fix this?

I edited the file, did a new python setup.py install and python quickstart.py

Traceback (most recent call last):
  File "quickstart.py", line 1, in <module>
    from instapy import InstaPy
  File "/var/www/virtual/myusername/instapy/InstaPy/instapy/__init__.py", line 1, in <module>
    from .instapy import InstaPy
  File "/var/www/virtual/myusername/instapy/InstaPy/instapy/instapy.py", line 37
    self.logFile = open('./logs/logFile.txt', 'a')
    ^
IndentationError: unexpected indent

@tibor check the indentation in instapy.py after the edit.
IndentationError: unexpected indent

I followed the recomendations above, but I got the following response:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-66-generic x86_64)

I need to do a VNC access?

@CleytonBonamigo check the ./assets/chromedriver.log file for the details.

@vlntdds, I checked but have no idea what happened.

[1.011][INFO]: COMMAND InitSession {
   "desiredCapabilities": {
      "browserName": "chrome",
      "chromeOptions": {
         "args": [ "--dns-prefetch-disable", "--no-sandbox", "--lang=en-US" ],
         "extensions": [  ],
         "prefs": {
            "intl.accept_languages": "en-US"
         }
      },
      "javascriptEnabled": true,
      "platform": "ANY",
      "version": ""
   },
   "requiredCapabilities": {

   }
}
[1.013][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "intl": {
      "accept_languages": "en-US"
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1.014][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[1.016][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --dns-prefetch-disable --enable-automation --enable-logging --ignore-certificate-errors --lang=en-US --load-extension=/tmp/.org.chromium.Chromium.ZHeLu1/internal --log-level=0 --metrics-recording-only --no-first-run --no-sandbox --password-store=basic --remote-debugging-port=12416 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.sqJmiE data:,
[1.017][DEBUG]: DevTools request: http://localhost:12416/json/version
[1.129][DEBUG]: DevTools request failed
[1.179][DEBUG]: DevTools request: http://localhost:12416/json/version
[1.180][DEBUG]: DevTools request failed
[23902:23902:0406/202804.148330:ERROR:browser_main_loop.cc(279)] Gtk: cannot open display: 
[0406/202804.152310:ERROR:nacl_helper_linux.cc(311)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
[1.230][DEBUG]: DevTools request: http://localhost:12416/json/version
[1.230][DEBUG]: DevTools request failed
.
.
.
[61.050][DEBUG]: DevTools request: http://localhost:12416/json/version
[61.051][DEBUG]: DevTools request failed
[61.060][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: exited abnormally
[61.064][DEBUG]: Log type 'driver' lost 0 entries on destruction
[61.065][DEBUG]: Log type 'browser' lost 0 entries on destruction

@CleytonBonamigo uncomment all display lines in instapy.py

Hi, after installing try to put example code into a script but give me this error:
python bellboyaudifonos.py Traceback (most recent call last): File "bellboyaudifonos.py", line 2, in <module> from instapy import InstaPy ImportError: No module named instapy

@vlntdds It worked, but now I'm having another error.

Done waiting for pending navigations. Status: tab crashed
[0407/010544.635049:ERROR:nacl_helper_linux.cc(311)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
RESPONSE Navigate unknown error: session deleted because of page crash
from tab crashed
  (Session info: chrome=57.0.2987.133)

This happens when begins to search for the first tag.
I tried to search on web, but no one solution worked.

@CleytonBonamigo are you running with sudo?
Seems that chrome doesn't start with sudo when running without sandbox.
Give a try with and without sudo

@n3rio put your script outside the instapy folder.

@vlntdds I run with and without sudo. On both times, showed me the same error.
I even try to add parameter chrome_options.add_argument('--user-data-dir') to run with sudo, with no success.

on it @vlntdds at 10kbps, welcome to vzla

@CleytonBonamigo are you running in a local machine or it's a VM somewhere? Could you provide more details about the machine configuration?

@vlntdds sure. I'm running on a U$5,00 Digital Ocean droplet, with Ubuntu 16.04.

@CleytonBonamigo try upgrading it to a 10$ one and running the script again.
This might be due to Chrome eating up to much RAM.

I checked all intents and now the last error message is gone. However, quickstart.py ends still with selenium.common.exceptions.WebDriverException: Message: Service ./assets/chromedriver unexpectedly exited. Status code was: 1.

The file logs/logFile.txt is empty.

@timgrossmann yeah dude, it was that. Thanks.

@CleytonBonamigo perfect!

Was this page helpful?
0 / 5 - 0 ratings