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
d908c1ab
...
d908c1ab44901e7224167895b941c58cadc2b7f2
authored
2012-01-21 09:48:16 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added metaextract sample scripts
1 parent
930f368c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
docs
samples/metaextract.coffee
samples/metaextract.js
tests/run.js
docs
@
2029165d
Subproject commit
50c9d3f003479ee6b62249a5ad33fa3648e9da
a9
Subproject commit
2029165d028c53aa9223e75d2505dd3b8a9002
a9
...
...
samples/metaextract.coffee
0 → 100644
View file @
d908c1a
casper
=
require
(
"casper"
).
create
()
url
=
casper
.
cli
.
get
0
metas
=
[]
if
not
url
casper
.
echo
"Usage: casperjs [url]"
casper
.
exit
()
casper
.
start
url
,
->
metas
=
@
evaluate
->
metas
=
[]
castarray
=
(
arr
)
->
[].
slice
.
call
(
arr
)
for
elem
in
castarray
document
.
querySelectorAll
"meta"
meta
=
{}
for
attr
in
castarray
elem
.
attributes
meta
[
attr
.
name
]
=
attr
.
value
metas
.
push
meta
metas
casper
.
run
->
require
(
"utils"
).
dump
metas
this
.
exit
()
samples/metaextract.js
0 → 100644
View file @
d908c1a
var
casper
=
require
(
"casper"
).
create
()
,
url
=
casper
.
cli
.
get
(
0
)
,
metas
=
[];
if
(
!
url
)
{
casper
.
echo
(
'Usage: casperjs [url]'
).
exit
();
}
casper
.
start
(
url
,
function
()
{
metas
=
this
.
evaluate
(
function
()
{
var
metas
=
[];
[].
forEach
.
call
(
document
.
querySelectorAll
(
'meta'
),
function
(
elem
)
{
var
meta
=
{};
[].
slice
.
call
(
elem
.
attributes
).
forEach
(
function
(
attr
)
{
meta
[
attr
.
name
]
=
attr
.
value
;
});
metas
.
push
(
meta
);
});
return
metas
;
});
});
casper
.
run
(
function
()
{
require
(
"utils"
).
dump
(
metas
);
this
.
exit
();
});
tests/run.js
View file @
d908c1a
...
...
@@ -13,7 +13,7 @@ var casper = require('casper').create({
// Overriding Casper.open to prefix all test urls
casper
.
setFilter
(
'open.location'
,
function
(
location
)
{
if
(
!
/^http/
.
test
(
location
))
{
return
'file://'
+
phantom
.
casperPath
+
'/'
+
location
;
return
f
(
'file://%s/%s'
,
phantom
.
casperPath
,
location
)
;
}
return
location
;
});
...
...
Please
register
or
sign in
to post a comment