-
-
Save DelphiQin/b4f3efe40bc77a17b28d to your computer and use it in GitHub Desktop.
crawl appannie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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