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
46882628
...
46882628ca57fb74b3daad8399838295e932dcf1
authored
2012-09-21 17:24:07 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed #239 - getPageContent() was broken
1 parent
5ed461e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
docs
modules/casper.js
docs
@
60c0d5d1
Subproject commit
54ebcf8d7d29559d400401f6752fc770317439a1
Subproject commit
60c0d5d1e109257f31a2ef65fcc0d1f89a54a67a
...
...
modules/casper.js
View file @
4688262
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom require*/
/*global CasperError console exports phantom require
__utils__
*/
var
colorizer
=
require
(
'colorizer'
);
var
events
=
require
(
'events'
);
...
...
@@ -587,7 +587,6 @@ Casper.prototype.exit = function exit(status) {
"use strict"
;
this
.
emit
(
'exit'
,
status
);
phantom
.
exit
(
status
);
return
this
;
};
/**
...
...
@@ -709,12 +708,14 @@ Casper.prototype.getPageContent = function getPageContent() {
return
this
.
page
.
content
;
}
// for some reason webkit/qtwebkit will always enclose body contents within html tags
var
match
=
(
new
RegExp
(
'^<html><head></head><body><pre.+?>(.*)</pre></body></html>$'
)).
exec
(
this
.
page
.
content
);
if
(
!
match
)
{
// Non-HTML response
return
this
.
page
.
content
;
}
return
match
[
1
];
var
sanitizedHtml
=
this
.
evaluate
(
function
checkHtml
()
{
if
(
__utils__
.
findOne
(
'head'
).
childNodes
.
length
===
0
&&
__utils__
.
findOne
(
'body'
).
childNodes
.
length
===
1
&&
__utils__
.
findOne
(
'body pre[style]'
))
{
return
__utils__
.
findOne
(
'body pre'
).
textContent
.
trim
();
}
});
return
sanitizedHtml
?
sanitizedHtml
:
this
.
page
.
content
;
};
/**
...
...
Please
register
or
sign in
to post a comment