Pergunta

Fairly excited about this utility, but running into some issues with implementation. Installed it but getting no result with execution of HTML file on server. Syntax error on the URL code.

<script LANGUAGE="JavaScript" SRC="boilerpipe-1.1.0.jar">
</script>

<script type="text/javascript">


 URL url = new URL("http://www.mywebsite.com");
 var text = ArticleExtractor.INSTANCE.getText(url);

document.write(text);

</script>

EDIT =====> This code appears to have worked.

<?php 


$html = file_get_contents("http://www.google.com");

?>


<script language="JavaScript" src="boilerpipe-1.1.0.jar"></script>


<script language="javascript" type="text/javascript">

  var sStr = "<?php echo $html?>";

  var text = ArticleExtractor.INSTANCE.getText(sStr);

document.write(text); 

?>

Foi útil?

Solução

Boilerpipe is a Java library, not a JavaScript library. The relationship between the two languages is only slightly deeper then the relationship between a Car and a Carpet.

If you want to use Boilerpipe within a webpage then you'll need to either write a Java Applet that exposes the API to JavaScript, or write a web service that exposes it over HTTP (and then access it using Ajax).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top