PHP matches the class div in HTML and selects the contents of the method, Classdiv
The example in this paper is a method that PHP matches the div in HTML with class and selects the content. Share to everyone for your reference. The specific analysis is as follows:
Let's take a look at some HTML code:
Copy the Code code as follows:
Tide Table data for reference only
Tide Time (Hrs) |
00:58 |
05:20 |
13:28 |
21:15 |
High tide (CM) |
161 |
75 |
288 |
127 |
Time zone:-1000 (East 10) Tidal height datum: 174CM at mean sea level
This is part of the source program, in order to be easy to understand, cut a large part, just take the contents of the DIV block
Home first Use file_get_content or curl to get the content part, I use curl.
Copy the Code code as follows: $ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_postfields, $data);
$return = curl_exec ($ch);
Curl_close ($ch);
$regex 4= "/.*?<\/div>/ism";
if (Preg_match_all ($regex 4, $return, $matches)) {
Print_r ($matches);
}else{
echo ' 0 ';
}
This is OK, not much explanation, understand the PHP code, print to see the effect.
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/942409.html www.bkjia.com true http://www.bkjia.com/PHPjc/942409.html techarticle PHP matches the class div in HTML and selects the contents of the method, classdiv the example of PHP matches the class Div in the HTML and select the contents of the method. Share to everyone ...