Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samundrak/9841d9039c69a8bedbed to your computer and use it in GitHub Desktop.
Save samundrak/9841d9039c69a8bedbed to your computer and use it in GitHub Desktop.
<?php
$url = 'http://www.wordpress.com';
// $header [] = "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
// $header [] = "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3";
// $header [] = "Accept-Encoding:gzip,deflate";
// $header [] = "Accept-Language:en-US,en;q=0.5";
// $user_cookie = "cookies.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_HEADER, 1);
// curl_setopt($ch,CURLOPT_TIMEOUT,20);
// curl_setopt($ch,CURLOPT_PORT,9119);
curl_setopt($ch,CURLOPT_REFERER,'http://google.com');
// curl_setopt($ch, CURLOPT_HTTPHEADER, $header );
curl_setopt($ch,CURLOPT_USERAGENT,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 GTB7.1 (.NET CLR 3.5.30729)");
// curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,20);
// curl_setopt($ch, CURLOPT_ENCODING, "identity");
// curl_setopt($ch, CURLOPT_COOKIEFILE, $user_cookie);
// curl_setopt($ch, CURLOPT_COOKIEJAR, $user_cookie);
// curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POST, true);
// $data = array(
// 'username' => 'samundrak',
// 'password' => 'pas',
// 'rememberme' => 'on'
// );
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-type: text/plain'));
$output = curl_exec($ch);
$info = curl_getinfo($ch);
echo $output;
curl_close($ch);
//print_R($info);
?>
<?php
//OOP Way
// $scrapper = new scrapper();
// echo $scrapper->show();
// class scrapper{
// private $symbol;
// private $url;
// public function __construct(){
// $this->url = "http://www.wordpress.com";
// }
// private static function resultExec($url,$symbol){
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_POST, true);
// // $data = array(
// // 'symbol' => $symbol,
// // 'Submit' => 'Submit'
// // );
// // curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// $output = curl_exec($ch);
// $info = curl_getinfo($ch);
// curl_close($ch);
// return $output;
// }
// private function writeFile(){
// $openFile = fopen("result.txt","w");
// fwrite($openFile,self::resultExec($this->url,$this->symbol));
// }
// public function show(){
// $this->writeFile();
// $show = file_get_contents("result.txt");
// echo $show;
// unlink('result.txt');
// }
// }
?>
@samundrak
Copy link
Author

uncomment the extra options as u want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment