steffenz

Untitled

Sep 25th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2.  
  3. $page = get_web_page("http://search.ebscohost.com/login.aspx?authtype=ip,uid&profile=ehost&defaultdb=buh");
  4.  
  5. // Henter kun ut URL skriv eventuelt print_r(page) for å få ut all info
  6. echo $page['url'];
  7.  
  8. function get_web_page( $url )
  9. {
  10.     $options = array(
  11.         CURLOPT_RETURNTRANSFER => true,     // return web page
  12.         CURLOPT_HEADER         => false,    // don't return headers
  13.         CURLOPT_FOLLOWLOCATION => true,     // follow redirects
  14.         CURLOPT_ENCODING       => "",       // handle all encodings
  15.         CURLOPT_USERAGENT      => "spider", // who am i
  16.         CURLOPT_AUTOREFERER    => true,     // set referer on redirect
  17.         CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
  18.         CURLOPT_TIMEOUT        => 120,      // timeout on response
  19.         CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
  20.     );
  21.  
  22.     $ch      = curl_init( $url );
  23.     curl_setopt_array( $ch, $options );
  24.     $content = curl_exec( $ch );
  25.     $err     = curl_errno( $ch );
  26.     $errmsg  = curl_error( $ch );
  27.     $header  = curl_getinfo( $ch );
  28.     curl_close( $ch );
  29.  
  30.     $header['errno']   = $err;
  31.     $header['errmsg']  = $errmsg;
  32.     $header['content'] = $content;
  33.     return $header;
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment