Skip to content

Commit

Permalink
add addition args for phantomjs
Browse files Browse the repository at this point in the history
  • Loading branch information
binux committed Nov 21, 2015
1 parent fcf5bfd commit 6b71bb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion docs/Command-Line.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,21 @@ phantomjs
---------

```
Usage: pyspider phantomjs [OPTIONS]
Usage: run.py phantomjs [OPTIONS] [ARGS]...
Run phantomjs fetcher if phantomjs is installed.
Options:
--phantomjs-path TEXT phantomjs path
--port INTEGER phantomjs port
--auto-restart TEXT auto restart phantomjs if crashed
--help Show this message and exit.
```

#### ARGS

Addition args pass to phantomjs command line.

fetcher
-------

Expand Down
6 changes: 5 additions & 1 deletion docs/apis/Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ Content of response, in bytes.

### Response.doc

A [PyQuery](https://pythonhosted.org/pyquery/) object of the request's content. Links have made as absolute by default.
A [PyQuery](https://pythonhosted.org/pyquery/) object of the response's content. Links have made as absolute by default.

Refer to the documentation of PyQuery: [https://pythonhosted.org/pyquery/](https://pythonhosted.org/pyquery/)

It's important that I will repeat, refer to the documentation of PyQuery: [https://pythonhosted.org/pyquery/](https://pythonhosted.org/pyquery/)

### Response.etree

A [lxml](http://lxml.de/) object of the response's content.

### Response.json

The JSON-encoded content of the response, if any.
Expand Down
8 changes: 4 additions & 4 deletions pyspider/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ def webui(ctx, host, port, cdn, scheduler_rpc, fetcher_rpc, max_rate, max_burst,
@click.option('--phantomjs-path', default='phantomjs', help='phantomjs path')
@click.option('--port', default=25555, help='phantomjs port')
@click.option('--auto-restart', default=False, help='auto restart phantomjs if crashed')
@click.argument('args', nargs=-1)
@click.pass_context
def phantomjs(ctx, phantomjs_path, port, auto_restart):
def phantomjs(ctx, phantomjs_path, port, auto_restart, args):
"""
Run phantomjs fetcher if phantomjs is installed.
"""
Expand All @@ -386,11 +387,10 @@ def phantomjs(ctx, phantomjs_path, port, auto_restart):
phantomjs_fetcher = os.path.join(
os.path.dirname(pyspider.__file__), 'fetcher/phantomjs_fetcher.js')
cmd = [phantomjs_path,
'--ssl-protocol=any',
'--disk-cache=true',
# this may cause memory leak: https://github.com/ariya/phantomjs/issues/12903
#'--load-images=false',
phantomjs_fetcher, str(port)]
'--ssl-protocol=any',
'--disk-cache=true'] + list(args or []) + [phantomjs_fetcher, str(port)]

try:
_phantomjs = subprocess.Popen(cmd)
Expand Down

0 comments on commit 6b71bb3

Please sign in to comment.