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
f5d21fc3
...
f5d21fc39013f95ba59b644c59cae6c43e27f0d4
authored
2012-01-09 16:53:28 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed obsolete use of Casper.extend in samples
1 parent
d433cf8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
17 deletions
samples/googlematch.coffee
samples/googlematch.js
samples/googlematch.coffee
View file @
f5d21fc
...
...
@@ -10,15 +10,13 @@ Usage:
winner is "nicolas" with 69600000 results
###
CasperClass
=
require
(
'casper'
).
Casper
casper
=
require
(
'casper'
).
create
verbose
:
true
CasperClass
.
extend
fetchScore
:
->
@
evaluate
->
casper
.
fetchScore
=
->
@
evaluate
->
result
=
document
.
querySelector
(
'#resultStats'
).
innerText
~~
(
/Environ ([0-9\s]{1,}).*/
.
exec
(
result
)[
1
].
replace
(
/\s/g
,
''
))
casper
=
new
CasperClass
verbose
:
true
terms
=
casper
.
cli
.
args
# terms are passed through command-line arguments
if
terms
.
length
<
3
...
...
samples/googlematch.js
View file @
f5d21fc
...
...
@@ -9,21 +9,17 @@
* borris: 2370000
* winner is "nicolas" with 69600000 results
*/
var
CasperClass
=
require
(
'casper'
).
Casper
;
CasperClass
.
extend
({
fetchScore
:
function
()
{
return
this
.
evaluate
(
function
()
{
var
result
=
document
.
querySelector
(
'#resultStats'
).
innerText
;
return
~~
(
/Environ
([
0-9
\s]{1,})
.*/
.
exec
(
result
)[
1
].
replace
(
/
\s
/g
,
''
));
});
}
});
var
casper
=
new
CasperClass
({
var
casper
=
new
require
(
'casper'
).
create
({
verbose
:
true
}),
terms
=
casper
.
cli
.
args
,
scores
=
[],
i
=
0
;
casper
.
fetchScore
=
function
()
{
return
this
.
evaluate
(
function
()
{
var
result
=
document
.
querySelector
(
'#resultStats'
).
innerText
;
return
~~
(
/Environ
([
0-9
\s]{1,})
.*/
.
exec
(
result
)[
1
].
replace
(
/
\s
/g
,
''
));
});
};
if
(
terms
.
length
<
2
)
{
casper
.
echo
(
'Usage: casperjs googlematch.js term1, term2 [, term3]...'
).
exit
();
}
...
...
Please
register
or
sign in
to post a comment