PHP-readability not working
I am using https://github.com/feelinglucky/php-readability and I am able to get the author's example to work. However, when I made my own, it just outputs the url. Does anyone know what is wrong with my code?
Here is my code:
<?php
require 'lib/Readability.inc.php';
$source = 'http://techcrunch.com/2011/04/02/conduit-acquires-web-application-platform-wibiya-for-45-million-sources/';
$Readability = new Readability($source, $html_input_charset); //default charset is utf-8
$ReadabilityData = $Readability->getContent();
$title = $ReadabilityData['title'];
$content = $ReadabilityData['content'];
?>
<html>
<head>
<title>test - <?php echo $title; ?></title>
</head>
<body>
<?php
echo "<h1>". $title."</h1> ";
echo $content;
?>
</body>
</html>
and this is t开发者_开发技巧he output I get:
<html>
<head>
<title>test - </title>
</head>
<body>
<h1></h1> <body contentScore="105"><p>http://techcrunch.com/2011/04/02/conduit-acquires-web-application-platform-wibiya-for-45-million-sources/</p></body>
</body>
</html>
the output that I am looking for is like this: https://lab.gracecode.com/readability/?url=http%3A%2F%2Ftechcrunch.com%2F2011%2F04%2F02%2Fconduit-acquires-web-application-platform-wibiya-for-45-million-sources%2F
You are supposed to feed it a html document.
$source = 'http://techcrunch.com/2011/04/02/conduit-acquires-web-application-platform-wibiya-for-45-million-sources/';
$html = file_get_contents($source);
$Readability = new Readability($html, $html_input_charset);
...
精彩评论