Skip to content

Instantly share code, notes, and snippets.

@imvkmark
Last active December 16, 2015 21:29
Show Gist options
  • Save imvkmark/5499839 to your computer and use it in GitHub Desktop.
Save imvkmark/5499839 to your computer and use it in GitHub Desktop.
php:curl
<?php
/*
* 采集诸葛网的代码
* @package bbs
* @author Mark
* @copyright Copyright (c) 2013 mark team
* @version $Id$
*/
$downloadUrl = "http://d.zgxcw.com.cn/download.php?LzIwMTMtMDQtMjgvNjVkZmI2M2FjMzdjOGFhYTZjNTgzMjdmNjYxNDI4NDYucGRmJuWbvuino@`1^1@axvei9puaehOmAoOS4juWOn@`1^1@eQhi5wZGY=";
$ch = curl_init();
$falseIP = falseIp();
curl_setopt ($ch, CURLOPT_URL, $downloadUrl);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$falseIP, 'CLIENT-IP:'.$falseIP));
curl_setopt ($ch, CURLOPT_REFERER, "http://www.zgxcw.com.cn/?docs-docsdetail-9753");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec ($ch);
$utf8file = '这里是中文名.pdf';
$gbkFile = iconv('utf-8', 'gbk', $utf8file);
touch($gbkFile);
var_dump(file_put_contents($gbkFile, $content));
curl_close ($ch);
function falseIp(){
return rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255);
}
<?php
// orginal
$url = "http://api.rrs.com/api/extend/user/check-session";
$post_data = array(
'channel' => 'mobile-site',
'session' => '8f1a94fbZf528764dZ14959ce8facZeac4',
'sign' => '2fdf1d3f5cdf4a0425e2c4dc3b896086',
);
// combine
$url_full = $url . '?' . http_build_query($post_data);
// opt
$options = array(
CURLOPT_URL => $url_full,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$output = curl_exec($ch);
// output
echo ($output);
// {"status":200,"data":{"success":true,"result":6799569,"sign":"18cee71ab503e47f55e201079604c9ec","sessionId":"8f1a94fbZf528764dZ14959ce8facZeac4"}}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment