Advertisement
Guest User

Untitled

a guest
May 11th, 2012
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['url'])) {
  3.     $curl = curl_init();
  4.     curl_setopt($curl, CURLOPT_URL, 'http://www.google.com/url?q='.urlencode($_POST['url']));
  5.     curl_setopt($curl, CURLOPT_HEADER, false);
  6.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  7.     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,  0);
  8.     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  9.     curl_setopt($curl, CURLOPT_SSLVERSION, 3);
  10.     curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21");
  11.     $page = curl_exec($curl);
  12.    
  13.     $dom = new domDocument;
  14.     @$dom->loadHTML($page);
  15.     $dom->preserveWhiteSpace = false;
  16.    
  17.     $a = $dom->getElementsByTagName('a');
  18.     echo 'http://www.google.com' . $a->item(0)->getAttribute('href');
  19. } else {
  20.     ?>
  21.     <form method="POST">
  22.     Url: <input name="url" />
  23.     <br /><input type="submit" value="Generate url!" />
  24.     </form>
  25.     <?php
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement