Created
April 14, 2018 14:05
-
-
Save BANKA2017/7b8a703c345f947229678cfac2b03f9a to your computer and use it in GitHub Desktop.
apkpure的apk文件抓取
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 | |
$task = json_decode(file_get_contents(dirname(__FILE__) . "/task.json"), 1); | |
for ($x = 0; $x < count($task); $x++) { | |
$name = $task[$x]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_URL, "https://m.apkpure.com/cn/{$name[0]}"); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$contents = curl_exec($ch); | |
curl_close($ch); | |
preg_match('/<p class=\\"details-sdk\\"><span>(.+?) <\\/span>/', $contents, $a); | |
if ($a[1] != $name[1]) { | |
$task[$x][1] = $a[1]; | |
echo "{$name[0]}:开始更新{$a[1]}\n"; | |
$url = "https://m.apkpure.com/cn/{$name[0]}/download?from=details"; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_REFERER, $url); | |
$contents = curl_exec($ch); | |
curl_close($ch); | |
preg_match('/<iframe id=\\"iframe_download\\" src=\\"(.+?)\\">/', $contents, $a); | |
$fp = fopen(dirname(__FILE__) . "/{$task[$x][1]}.{$name[0]}.apk", "w"); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_URL, $a[1]); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_REFERER, $url); | |
curl_setopt($ch, CURLOPT_FILE, $fp); | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
echo "{$name[0]}:已更新\n"; | |
} else { | |
echo "{$name[0]}:无更新\n"; | |
} | |
} | |
file_put_contents(dirname(__FILE__) . "/task.json", json_encode($task)); |
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
[["com.example.app",null]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment