Skip to content

Commit 39cfc19

Browse files
committed
Merge pull request n1k0#15 from salty-horse/is_readerable
Show output of isProbablyReaderable()
2 parents 3ad894a + d091c4b commit 39cfc19

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

phantom-scrape.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ function runReadability(url, userAgent, pageContent) {
3131
pathBase: location.protocol + "//" + location.host + location.pathname.substr(0, location.pathname.lastIndexOf("/") + 1)
3232
};
3333
try {
34-
var result = new Readability(uri, document).parse();
34+
var readabilityObj = new Readability(uri, document);
35+
var isProbablyReaderable = readabilityObj.isProbablyReaderable();
36+
var result = readabilityObj.parse();
3537
if (result) {
3638
result.userAgent = userAgent;
39+
result.isProbablyReaderable = isProbablyReaderable;
3740
} else {
3841
result = {
3942
error: {

static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ <h1>Readability.js <small>test page</small></h1>
5050
</div>
5151
<div class="col-md-6">
5252
<table class="table table-striped">
53+
<tr><th>Readerable?</th><td id="readerable"></td></tr>
5354
<tr><th>Title</th><td id="title"></td></tr>
5455
<tr><th>Dir</th><td id="dir"></td></tr>
5556
<tr><th>Byline</th><td id="byline"></td></tr>

static/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
if (jsonResponse.error) {
1818
q("#error").textContent = jsonResponse.error.message;
1919
q("#error").classList.remove("hide");
20+
q("#readerable").textContent = "";
2021
q("#title").textContent = "";
2122
q("#byline").textContent = "";
2223
q("#length").textContent = "";
@@ -26,6 +27,7 @@
2627
target.contentDocument.body.innerHTML = "";
2728
} else {
2829
q("#error").textContent = "";
30+
q("#readerable").textContent = jsonResponse.isProbablyReaderable;
2931
q("#title").textContent = jsonResponse.title;
3032
q("#byline").textContent = jsonResponse.byline;
3133
q("#length").textContent = jsonResponse.length;

0 commit comments

Comments
 (0)