Advertisement
Guest User

Untitled

a guest
Mar 20th, 2015
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.03 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html>
  3.     <head>
  4.         <title>!</title>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  6.     </head>
  7. <body dir="rtl">
  8. <?php
  9. include_once 'Readability.php';
  10.  
  11.  
  12. // get latest Medialens alert
  13. // (change this URL to whatever you'd like to test)
  14. $url = 'http://';
  15. $html = file_get_contents($url);
  16. // Note: PHP Readability expects UTF-8 encoded content.
  17. // If your content is not UTF-8 encoded, convert it
  18. // first before passing it to PHP Readability.
  19. // Both iconv() and mb_convert_encoding() can do this.
  20. // If we've got Tidy, let's clean up input.
  21. // This step is highly recommended - PHP's default HTML parser
  22. // often doesn't do a great job and results in strange output.
  23. if (function_exists('tidy_parse_string')) {
  24.    $tidy = tidy_parse_string($html, array(), 'UTF8');
  25.    $tidy->cleanRepair();
  26.     $html = $tidy->value;
  27. }
  28.  
  29. // give it to Readability
  30. $readability = new Readability($html, $url);
  31. // print debug output?
  32. // useful to compare against Arc90's original JS version -
  33. // simply click the bookmarklet with FireBug's console window open
  34. $readability->debug = false;
  35. // convert links to footnotes?
  36. $readability->convertLinksToFootnotes = true;
  37. // process it
  38. $result = $readability->init();
  39. // does it look like we found what we wanted?
  40. if ($result) {
  41.     echo "== Title =====================================\n";
  42.     echo $readability->getTitle()->textContent, "\n\n";
  43.     echo "== Body ======================================\n";
  44.     $content = $readability->getContent()->innerHTML;
  45.     // if we've got Tidy, let's clean it up for output
  46.     if (function_exists('tidy_parse_string')) {
  47.         $tidy = tidy_parse_string($content, array('indent'=>true, 'show-body-only' => true), 'UTF8');
  48.         $tidy->cleanRepair();
  49.         $content = $tidy->value;
  50.     }
  51.     echo $content;
  52. } else {
  53.     echo 'Looks like we couldn\'t find the content. :(';
  54. }
  55. ?>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement