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
5ad676ab
...
5ad676ab1d07ab8a731a917097a056fc241148cc
authored
2012-05-09 08:34:50 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added js version of samples/googlepagination.coffee
1 parent
5f759b5f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletions
samples/googlepagination.coffee
samples/googlepagination.js
samples/googlepagination.coffee
View file @
5ad676a
...
...
@@ -4,7 +4,7 @@
#
# (all arguments will be used as the query)
casper
=
require
(
'casper'
).
create
(
verbose
:
true
,
logLevel
:
"debug"
)
casper
=
require
(
'casper'
).
create
()
currentPage
=
1
if
casper
.
cli
.
args
.
length
==
0
...
...
samples/googlepagination.js
0 → 100644
View file @
5ad676a
var
casper
,
currentPage
,
processPage
;
casper
=
require
(
'casper'
).
create
();
currentPage
=
1
;
if
(
casper
.
cli
.
args
.
length
===
0
)
{
casper
.
echo
(
"usage: $ casperjs my search terms"
);
casper
.
exit
();
}
processPage
=
function
()
{
var
url
;
this
.
echo
(
"capturing page "
+
currentPage
);
this
.
capture
(
"google-results-p"
+
currentPage
+
".png"
);
if
(
currentPage
>=
5
)
{
return
;
}
if
(
this
.
exists
(
"#pnnext"
))
{
currentPage
++
;
this
.
echo
(
"requesting next page: "
+
currentPage
);
url
=
this
.
getCurrentUrl
();
return
this
.
thenClick
(
"#pnnext"
).
then
(
function
()
{
return
this
.
waitFor
(
function
()
{
return
url
!==
this
.
getCurrentUrl
();
},
processPage
);
});
}
else
{
return
this
.
echo
(
"that's all, folks."
);
}
};
casper
.
start
(
'http://google.fr/'
,
function
()
{
return
this
.
fill
(
'form[action="/search"]'
,
{
q
:
casper
.
cli
.
args
.
join
(
' '
)
},
true
);
});
casper
.
then
(
processPage
);
casper
.
run
();
\ No newline at end of file
Please
register
or
sign in
to post a comment