0

I have to automate the "imitation" of a "human" by using a webbrowser that supports javascript.

I need it because there is a javascript link on the website that can be only used if the webbrowser supports javascript, so curl/wget cannot do it.

Question: How can I do this on a Linux terminal? Or is it impossible?

1 Answers1

3

This can be done using two ways:

  1. GUI way ==> Use Selenium
  2. Terminal way ==> Use ghost.py or phantomjs

Terminal Way

You can go ahead and use ghost.py or phantomjs. Read their documentations on how to use them here : Ghost.py and phantomjs

An example using Ghost.py

First install ghost.py. To install this, you will need pip. Hence, do this on a ubuntu based system:

sudo apt-get install python-pip
sudo pip install Ghost.py

Now, you can use Ghost.py in your script to automate any javascript based actions. Here is a sample script derived from the official documentation:

#!/usr/bin/python
#script.py

from ghost import Ghost ghost = Ghost()

page, resources = ghost.open('http://my.web.page')

#Run javascript action result, resources = ghost.evaluate( "document.getElementById('my-input').getAttribute('value');")

shivams
  • 4,565