Scrapper

From My Wiki
Jump to: navigation, search
<?php

        if($_GET["u"] != ""){
                      $url0 = $_GET["u"];
                      $token = '60e91fb601a5ffaa231bb95f6a901ebe';
			$isyoutube = FALSE;
		if(strpos($url0,'youtube.com') !== false){
			$isyoutube = TRUE;
		}
                      $download = 'http://diffbot.com/api/article?token=' . $token . '&url=' . urlencode($url0);
                      $json = file_get_contents($download);
                      $obj = json_decode($json);

                      $text = $obj->{'text'};
                      $title = $obj->{'title'};
                      $url = $obj->{'url'};
?>
<html><head>
<meta charset="utf-8">
<style type="text/css">
  body {
  font-family: Georgia, Times, serif;
     font-size: 16px;
     word-wrap: break-word;
     margin: 90px auto 0px auto;
     padding-botton: 100px;
     position: relative;
     width: 800px;
     line-height: 1.5;
   background-color:#131313;
         color: #878787;
}
p {
display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
width: 605px;

         text-align:left;
}
h1 {
font-family: Georgia, Times, serif;color: #000;
font-size: 24px;
font-weight: normal;padding-bottom: 0;
margin-bottom: 0;
text-rendering: optimizeLegibility;
display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
width: 605px;
text-align:left;
 }
a {
text-decoration: none;
}
a:link {color:#878787;}      /* unvisited link */
a:visited {color:#878787;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */

</style>
</head>
<body>
<div align=center>
<?php
if($isyoutube==FALSE){
echo "<h1>";
echo "<a href=\"".$url."\" target=\"_blank\">".$title."</a>";
echo "</h1>";
        print "<p>";
        //print $text;
        //print nl2br($text);
        print str_replace("\n", "</p><p>", $text);
        print "</p>";
	print "<a href=\"".$url."\" target=\"_blank\">[View Original]</a>";
}else{
	$a = parse_url(urldecode($url0));
	$b = substr($a["query"],2);
	echo "<div style=\"margin: 50px auto 25px auto; width: 640px;\">";
	echo "<object width=\"640\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/";
	echo $b;
	echo "\"></param>
<param name=\"allowFullScreen\" value=\"true\"></param>
<embed src=\"http://www.youtube.com/v/";
	echo $b;
	echo "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"640\" height=\"385\"></embed></object>";
	echo "</div>";
}
?>
</div>
</body>
</html>
<?php }else{
      #show normal form
      ?>
<html>
        <form method="get" action="">
              url: <input type="text" name="u" />
                    <input type="submit" value="Submit" />
                    </form>
</html><?php
}
?>