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
d7458b17
...
d7458b17b646842ea40f5412a039019d20cbd8df
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
2 changed files
with
48 additions
and
0 deletions
samples/metaextract.coffee
samples/metaextract.js
samples/metaextract.coffee
0 → 100644
View file @
d7458b1
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 @
d7458b1
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
();
});
Please
register
or
sign in
to post a comment