-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcurl.php
More file actions
executable file
·38 lines (34 loc) · 1.11 KB
/
testcurl.php
File metadata and controls
executable file
·38 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*curl实例
*/
$num=20122110090223;
//$UP = 'user=jwc&pass=jwc';
$data = 'StuID='.urlencode($num);
//$preurl = 'http://jwc.ecjtu.jx.cn/mis_o/login.php';
$mainurl ='http://jwc.ecjtu.jx.cn/mis_o/query.php';
$curl = curl_init();
//
// 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, $mainurl);
// 设置header
curl_setopt($curl, CURLOPT_HEADER, 0);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_COOKIE,'PHPSESSID=54mptmt4d8rn2jgnpvj0ds6780');
// 运行cURL,请求网页
$data = curl_exec($curl);
if($data === false){
echo curl_error($curl); exit;
}
$info = curl_getinfo($curl);
// 关闭URL请求
curl_close($curl);
// 显示获得的数据
//var_dump($info);
echo $data;
$ttime=$info['total_time']+$info['namelookup_time']+$info['connect_time']+$info['pretransfer_time'];
echo 'total time waste:'.$ttime.'s';
////////////////the end of php curl
////////////////power by homker