-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
55 lines (43 loc) · 892 Bytes
/
demo.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by JetBrains PhpStorm.
* User: wuqunfei
* Date: 13-9-19
* Time: 14:21
*
*/
include 'uhttplib.php';
/**
* 1. GET Method
*
// */
$url = "http://www.python.org/";
$req = new UHttpLib($url, false, 60);
$response = $req->Get();
echo $response;
/**
* 2. Post Method
*/
$url = "http://www.google.com";
$req = new UHttpLib($url);
$response = $req->Post();
echo $response;
/**
* 3. With Request Params
*/
$url = "http://www.google.com";
$params = array();
$params['q'] = "moon cake";
$req = new UHttpLib($url, false, 60);
$response = $req->Get($params);
echo $response;
/**
* 4. Parse HTML
* Desc: get Shanghai's weather
*/
$url = "http://www.weather.com/weather/today/Shanghai+CHXX0116:1:CH";
$req = new UHttpLib($url);
$response = $req->Get();
$elementTree = $req->tree($response);
$doms = $elementTree->childNodes(".wx-temperature");
var_dump($doms);