You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 17, 2019. It is now read-only.
I've written it on Heroku, but it has my Mercury API hardcoded currently, so I don't have the source mirroring up here at the moment. I'll get that cleaned up and copied here for reference, but until then:
var http = require("http");
var url = require('url') ;
var Curl = require( 'node-libcurl' ).Curl;
var htmlToText = require('html-to-text');
function onRequest(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
var queryObject = url.parse(request.url, true).query;
if (typeof queryObject.url == "string") {
var processURL = queryObject.url;
var curl = new Curl();
curl.setOpt( "URL", 'https://mercury.postlight.com/parser?url=' + processURL); //https://trackchanges.postlight.com/building-awesome-cms-f034344d8ed' );
curl.setOpt( Curl.option.HTTPHEADER, ['x-api-key: xxxxxxx'] );
curl.on( 'end', function( statusCode, body, headers ) {
var r = JSON.parse(body);
var o = htmlToText.fromString(r.content, { ignoreHref: true, ignoreImage: true, uppercaseHeadings: false, wordwrap: false });
response.write(o);
response.end();
this.close();
});
curl.on( 'error', function() {
this.close();
response.write("There was a problem processing your request. Please select the text you want to read, right-click, and Read the selected text.");
response.end();
});
curl.perform();
} else {
response.write("There was a problem processing your request. Please select the text you want to read, right-click, and Read the selected text.");
response.end();
}
}
var port = process.env.PORT || 5000;
http.createServer(onRequest).listen(port);
Do you have a full-featured local parser that doesn't add significant bloat to the project? If so, please PR and I'll drop the Mercury/Heroku solution and keep this fully local and close this issue.
Hi ! Where is the source for parser disclosed ? I can't find it, thanks.
The text was updated successfully, but these errors were encountered: