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
ca75a1e4
...
ca75a1e48bb7e846aa0f60b3b141448341e45a0d
authored
2012-05-21 12:00:36 +0200
by
Brikou CARRE
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(re) added 'name' to functions
1 parent
ab96d89c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
10 deletions
samples/bbcshots.js
samples/dynamic.js
samples/googlelinks.js
samples/googlepagination.js
samples/multirun.js
samples/bbcshots.js
View file @
ca75a1e
...
...
@@ -37,7 +37,7 @@ casper.start('http://www.bbc.co.uk/', function() {
});
});
var
next
=
function
()
{
var
next
=
function
next
()
{
var
image
=
"bbcshot"
+
currentLink
+
".png"
;
images
.
push
(
image
);
this
.
echo
(
"Processing image "
+
currentLink
);
...
...
@@ -53,7 +53,7 @@ var next = function() {
}
};
var
buildPage
=
function
()
{
var
buildPage
=
function
buildPage
()
{
this
.
echo
(
'Build result page'
);
var
fs
=
require
(
'fs'
);
this
.
viewport
(
624
,
400
);
...
...
samples/dynamic.js
View file @
ca75a1e
...
...
@@ -7,7 +7,7 @@ var upTo = ~~casper.cli.get(0) || 10; // max 10 links
// Fetch all <a> elements from the page and return
// the ones which contains a href starting with 'http://'
var
searchLinks
=
function
()
{
var
searchLinks
=
function
searchLinks
()
{
var
filter
=
Array
.
prototype
.
filter
;
var
map
=
Array
.
prototype
.
map
;
return
map
.
call
(
filter
.
call
(
document
.
querySelectorAll
(
"a"
),
function
(
a
)
{
...
...
@@ -25,7 +25,7 @@ var links = [
];
// Just opens the page and prints the title
var
start
=
function
(
link
)
{
var
start
=
function
start
(
link
)
{
this
.
start
(
link
,
function
()
{
this
.
echo
(
"Page title: "
+
(
this
.
getTitle
()));
});
...
...
@@ -33,7 +33,7 @@ var start = function(link) {
// Get the links, and add them to the links array
// (It could be done all in one step, but it is intentionally splitted)
var
addLinks
=
function
(
link
)
{
var
addLinks
=
function
addLinks
(
link
)
{
this
.
then
(
function
()
{
var
found
=
this
.
evaluate
(
searchLinks
);
this
.
echo
(
""
+
found
.
length
+
" links found on "
+
link
);
...
...
@@ -50,7 +50,7 @@ casper.then(function() {
var
currentLink
=
0
;
// As long as it has a next link, and is under the maximum limit, will keep running
var
check
=
function
()
{
var
check
=
function
check
()
{
if
(
links
[
currentLink
]
&&
currentLink
<
upTo
)
{
this
.
echo
(
"--- Link "
+
currentLink
+
" ---"
);
start
.
call
(
this
,
links
[
currentLink
]);
...
...
samples/googlelinks.js
View file @
ca75a1e
var
getLinks
=
function
()
{
var
getLinks
=
function
getLinks
()
{
var
links
;
links
=
document
.
querySelectorAll
(
"h3.r a"
);
return
Array
.
prototype
.
map
.
call
(
links
,
function
(
e
)
{
...
...
samples/googlepagination.js
View file @
ca75a1e
...
...
@@ -17,7 +17,7 @@ if (casper.cli.args.length === 0) {
;
}
var
processPage
=
function
()
{
var
processPage
=
function
processPage
()
{
var
url
;
this
.
echo
(
"capturing page "
+
currentPage
);
this
.
capture
(
"google-results-p"
+
currentPage
+
".png"
);
...
...
samples/multirun.js
View file @
ca75a1e
...
...
@@ -2,7 +2,7 @@ var casper = require('casper').create({
verbose
:
true
});
var
countLinks
=
function
()
{
var
countLinks
=
function
countLinks
()
{
return
document
.
querySelectorAll
(
'a'
).
length
;
};
...
...
@@ -42,7 +42,7 @@ casper.then(function() {
var
currentSuite
=
0
;
var
check
=
function
()
{
var
check
=
function
check
()
{
if
(
suites
[
currentSuite
])
{
suites
[
currentSuite
].
call
(
this
);
currentSuite
++
;
...
...
Please
register
or
sign in
to post a comment