PhantomJS - Command Line Interface



PhantomJS can be executed using the keyword "phantomjs" and the name of the file. For example, "phantomjs file.js".

You can also pass arguments into "file.js" as follows −

phantomjs [options] file.js arg1 arg2 ...

Let us go through some of the options available at the command line.

S.No Option & Description
1

--help or –h

Will display all the command line options. Halts immediately and will not run the script passed.

2

--version or –v

Prints the version of PhantomJS running. This will halt the execution of script to be run.

3

--debug[true|false]

Prints warnings and debug messages. By default, it is set to false. You can also use [yes|no].

4

--cookies-file = /path/to/cookies.txt

File name to store persistent cookies.

5

--diskcache=[true|false]

Enables disk cache. It also takes values [yes|no]

6

--disk-cahe-path

Path for disk cache.

7

--ignore-sslerrors=[true|false]

Ignore SSL errors. For example – Expired or self-signed certificate errors. Default is false. It also takes values [yes|no].

8

--loadimages=[true|false]

Loads all inline images. Default value is true. It also takes [yes|no].

9

--local-storagepath=/some/path

Path to save LocalStorage content and WebSQL content.

10

--local-storagequota=number

Maximum size to allow for data.

11

--local-url-access

Allows use of ‘file:///’ URLs (default is true).

12

--local-to-remote-urlaccess=[true|false]

Allows local content to access remote URL. Default is false. It also takes values [yes|no].

13

--max-disk-cachesize=size

Limits the size of disk cache (in KB)

14

--offline-storage-path

Specifies location for offline storage.

15

--offline-storage-quota

Sets the maximum size of the offline storage in KB.

16

--outputencoding=encoding

Sets the encoding used for terminal output. Default is utf-8.

17

--proxy=address:port

Specifies the proxy server to be used (For example – proxy=192.168.1.1:8080)

18

--proxytype=[http|socks5|none]

Specifies the type of proxy server (default is http)

19

--proxy-auth

Authentication information for the proxy. For example –

--proxy-auth=username:password

20

--scriptencoding=encoding

Sets the encoding used for the script. Default is utf8.

21

--script-language

Sets the script language.

Advertisements