Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
6853db45
...
6853db45f0d0160da6bc6a54f37cde4f39b10e26
authored
2012-05-20 03:57:26 -0700
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #113 from brikou/exit_code
added missing exit code (when errornous)
2 parents
5b02d6c6
2e7cde68
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
48 additions
and
24 deletions
samples/cliplay.coffee
samples/cliplay.js
samples/customlogging.coffee
samples/googlematch.coffee
samples/googlematch.js
samples/googlepagination.coffee
samples/googlepagination.js
samples/metaextract.coffee
samples/metaextract.js
samples/screenshot.coffee
samples/screenshot.js
samples/timeout.coffee
samples/timeout.js
samples/cliplay.coffee
View file @
6853db4
...
...
@@ -6,7 +6,9 @@ casper.cli.drop "cli"
casper
.
cli
.
drop
"casper-path"
if
casper
.
cli
.
args
.
length
is
0
and
Object
.
keys
(
casper
.
cli
.
options
).
length
is
0
casper
.
echo
(
"Pass some args and options to see how they are handled by CasperJS"
).
exit
()
casper
.
echo
(
"Pass some args and options to see how they are handled by CasperJS"
)
.
exit
(
1
)
casper
.
echo
"Casper CLI passed args:"
dump
casper
.
cli
.
args
...
...
samples/cliplay.js
View file @
6853db4
...
...
@@ -6,7 +6,10 @@ casper.cli.drop("cli");
casper
.
cli
.
drop
(
"casper-path"
);
if
(
casper
.
cli
.
args
.
length
===
0
&&
Object
.
keys
(
casper
.
cli
.
options
).
length
===
0
)
{
casper
.
echo
(
"Pass some args and options to see how they are handled by CasperJS"
).
exit
();
casper
.
echo
(
"Pass some args and options to see how they are handled by CasperJS"
)
.
exit
(
1
)
;
}
casper
.
echo
(
"Casper CLI passed args:"
);
...
...
samples/customlogging.coffee
View file @
6853db4
""" A basic custom logging implementation. The idea is to (extremely) verbosely
log every received resource.
"""
###
A basic custom logging implementation. The idea is to (extremely) verbosely
log every received resource.
###
casper
=
require
(
'casper'
).
create
# Every time a resource is received, a new log entry is added to the stack
...
...
samples/googlematch.coffee
View file @
6853db4
...
...
@@ -20,8 +20,9 @@ casper.fetchScore = ->
terms
=
casper
.
cli
.
args
# terms are passed through command-line arguments
if
terms
.
length
<
3
casper
.
echo
'Usage: casperjs googlematch.js term1, term2 [, term3]...'
casper
.
exit
()
casper
.
echo
'Usage: casperjs googlematch.js term1, term2 [, term3]...'
.
exit
(
1
)
scores
=
[]
...
...
samples/googlematch.js
View file @
6853db4
...
...
@@ -21,7 +21,10 @@ casper.fetchScore = function() {
};
if
(
terms
.
length
<
2
)
{
casper
.
echo
(
'Usage: casperjs googlematch.js term1, term2 [, term3]...'
).
exit
();
casper
.
echo
(
'Usage: casperjs googlematch.js term1, term2 [, term3]...'
)
.
exit
(
1
)
;
}
casper
.
echo
(
'Let the match begin!'
);
...
...
samples/googlepagination.coffee
View file @
6853db4
...
...
@@ -8,8 +8,9 @@ casper = require('casper').create()
currentPage
=
1
if
casper
.
cli
.
args
.
length
==
0
casper
.
echo
"usage: $ casperjs my search terms"
casper
.
exit
()
casper
.
echo
"usage: $ casperjs my search terms"
.
exit
(
1
)
processPage
=
->
@
echo
"capturing page
#{
currentPage
}
"
...
...
samples/googlepagination.js
View file @
6853db4
...
...
@@ -4,8 +4,10 @@ casper = require('casper').create();
currentPage
=
1
;
if
(
casper
.
cli
.
args
.
length
===
0
)
{
casper
.
echo
(
"usage: $ casperjs my search terms"
);
casper
.
exit
();
casper
.
echo
(
"usage: $ casperjs my search terms"
)
.
exit
(
1
)
;
}
processPage
=
function
()
{
...
...
@@ -37,4 +39,4 @@ casper.start('http://google.fr/', function() {
casper
.
then
(
processPage
);
casper
.
run
();
\ No newline at end of file
casper
.
run
();
...
...
samples/metaextract.coffee
View file @
6853db4
...
...
@@ -3,8 +3,9 @@ url = casper.cli.get 0
metas
=
[]
if
not
url
casper
.
echo
"Usage: casperjs [url]"
casper
.
exit
()
casper
.
echo
"Usage: casperjs [url]"
.
exit
(
1
)
casper
.
start
url
,
->
metas
=
@
evaluate
->
...
...
samples/metaextract.js
View file @
6853db4
...
...
@@ -3,7 +3,10 @@ var casper = require("casper").create()
,
metas
=
[];
if
(
!
url
)
{
casper
.
echo
(
'Usage: casperjs [url]'
).
exit
();
casper
.
echo
(
'Usage: casperjs [url]'
)
.
exit
(
1
)
;
}
casper
.
start
(
url
,
function
()
{
...
...
samples/screenshot.coffee
View file @
6853db4
...
...
@@ -11,8 +11,9 @@ twitterAccount = casper.cli.get 0
filename
=
casper
.
cli
.
get
1
if
not
twitterAccount
or
not
filename
or
not
/\.(png|jpg|pdf)$/i
.
test
filename
casper
.
echo
"Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
casper
.
exit
()
casper
.
echo
"Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
.
exit
(
1
)
casper
.
start
"https://twitter.com/#!/
#{
twitterAccount
}
"
,
->
capture
=
->
...
...
samples/screenshot.js
View file @
6853db4
...
...
@@ -14,8 +14,10 @@ var twitterAccount = casper.cli.get(0);
var
filename
=
casper
.
cli
.
get
(
1
);
if
(
!
twitterAccount
||
!
filename
||
!
/
\.(
png|jpg|pdf
)
$/i
.
test
(
filename
))
{
casper
.
echo
(
"Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
);
casper
.
exit
();
casper
.
echo
(
"Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
)
.
exit
(
1
)
;
}
casper
.
start
(
'https://twitter.com/#!/'
+
twitterAccount
,
function
()
{
...
...
samples/timeout.coffee
View file @
6853db4
...
...
@@ -21,8 +21,9 @@ casper = require('casper').create
timeout
=
~~
casper
.
cli
.
get
0
if
timeout
<
1
casper
.
echo
"You must pass a valid timeout value"
casper
.
exit
()
casper
.
echo
"You must pass a valid timeout value"
.
exit
(
1
)
casper
.
echo
"Will google.com load in less than
#{
timeout
}
ms?"
casper
.
options
.
timeout
=
timeout
...
...
samples/timeout.js
View file @
6853db4
...
...
@@ -22,7 +22,10 @@ var casper = require('casper').create({
var
timeout
=
~~
casper
.
cli
.
get
(
0
);
if
(
timeout
<
1
)
{
casper
.
echo
(
'You must pass a valid timeout value'
).
exit
();
casper
.
echo
(
'You must pass a valid timeout value'
)
.
exit
(
1
)
;
}
casper
.
echo
(
'Will google.com load in less than '
+
timeout
+
'ms?'
);
casper
.
options
.
timeout
=
timeout
;
...
...
@@ -31,4 +34,4 @@ casper.start('http://www.google.com/', function(self) {
self
.
echo
(
'YES!'
,
'GREEN_BAR'
).
exit
();
});
casper
.
run
();
\ No newline at end of file
casper
.
run
();
...
...
Please
register
or
sign in
to post a comment