Skip to content

Instantly share code, notes, and snippets.

@DelphiQin
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DelphiQin/b4f3efe40bc77a17b28d to your computer and use it in GitHub Desktop.
Save DelphiQin/b4f3efe40bc77a17b28d to your computer and use it in GitHub Desktop.
crawl appannie
<?php
$cookie_file = dirname(__FILE__)."/cookie.txt";
if(!file_exists($cookie_file)) {
echo "http cookie file not found, create.\n";
if(!touch($cookie_file)) {
echo "Could not create cookie.txt.\n";
}
}
$curl_opt_array = array(
CURLOPT_HEADER => true,
CURLOPT_AUTOREFERER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => array(
"Host" => "www.appannie.com",
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22",
"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Referer" => "http://www.appannie.com/",
"Connection" => "keep-alive",
"Cache-Control" => "max-age=0;",
"Accept-Encoding" => "gzip,deflate,sdch",
"Accept-Language" => "zh-CN,zh;q=0.8",
"Accept-Charset" => "GBK,utf-8;q=0.7,*;q=0.3",
),
CURLOPT_COOKIEJAR => $cookie_file,
CURLOPT_COOKIEFILE => $cookie_file,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true
);
$ch = curl_init();
curl_setopt_array($ch, $curl_opt_array);
curl_setopt($ch, CURLOPT_URL, "http://www.appannie.com/top/iphone/united-states/games/");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
$response = curl_exec($ch);
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment