This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URL; | |
import java.util.Scanner; | |
import de.l3s.boilerpipe.extractors.ArticleExtractor; | |
public class BoilerpipeCLI { | |
public static void main(String[] args) throws Exception { | |
String inputText = ""; | |
Scanner scanner = new Scanner(System.in); | |
while (scanner.hasNextLine()) { | |
inputText += scanner.nextLine()+"\n"; | |
} | |
String output = ArticleExtractor.INSTANCE.getText(inputText); | |
System.out.println(output); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'), | |
spawn = require('child_process').spawn; | |
request('http://yahoo.com', function (error, response, body) { | |
if (error) throw error; | |
if (response.statusCode !== 200) throw new Error('invalid statuscode: ' + response.statusCode); | |
if (!body) throw new Error('no body'); | |
var child = spawn('java', ['-classpath', './;./boilerpipe-1.2.0.jar;./lib/nekohtml-1.9.13.jar;./lib/xderces-2.9.1.jar', 'BoilerpipeCLI'], { | |
cwd: __dirname + '/lib/boilerpipe' | |
}), | |
output = ''; | |
child.stdout.on('data', function(data) { | |
console.log('writing output: ' + data); | |
output += data; | |
}); | |
child.on('exit', function() { | |
console.log('child exit'); | |
console.log(output); | |
}); | |
child.stdin.write(body, 'utf8'); | |
child.stdin.once('drain', function() { | |
child.stdin.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment