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
42d4b14f
...
42d4b14f52b538f770fe200db83c4b8b67f688cf
authored
2011-10-09 08:59:39 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
removed obsolete example.js
1 parent
96fc2436
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
44 deletions
example.js
example.js
deleted
100644 → 0
View file @
96fc243
phantom
.
injectJs
(
'casper.js'
);
function
q
()
{
document
.
querySelector
(
'input[name="q"]'
).
setAttribute
(
'value'
,
'%term%'
);
document
.
querySelector
(
'form[name="f"]'
).
submit
();
}
function
getLinks
()
{
var
links
=
document
.
querySelectorAll
(
'h3.r a'
);
return
[].
map
.
call
(
links
,
function
(
e
)
{
return
e
.
getAttribute
(
'href'
);
});
}
var
links
=
[];
var
casper
=
new
phantom
.
Casper
({
logLevel
:
"debug"
,
verbose
:
true
})
.
start
(
'http://google.fr/'
)
.
thenEvaluate
(
q
,
{
term
:
'casper'
,
})
.
then
(
function
(
self
)
{
links
=
self
.
evaluate
(
getLinks
);
})
.
thenEvaluate
(
q
,
{
term
:
'homer'
,
})
.
then
(
function
(
self
)
{
links
=
links
.
concat
(
self
.
evaluate
(
getLinks
));
self
.
log
(
"Click on 1st result link"
).
click
(
'h3.r a'
);
})
.
then
(
function
(
self
)
{
self
.
debugPage
();
})
.
run
(
function
(
self
)
{
self
.
echo
(
JSON
.
stringify
({
result
:
self
.
result
,
links
:
links
},
null
,
' '
));
self
.
exit
();
})
;
Please
register
or
sign in
to post a comment