Tips & nbsp; for new instructions, the difficulty lies in regular expressions, and regular expressions are not written. ------ solution ------------------ $ url & nbsp; h php crawls the data on this webpage. as long as the data is not html content, it then writes the json content into the file.
Http://www.okooo.com/Upload/sohu/table_23.html
I am asking for advice. the difficulty lies in regular expressions. I don't want to write regular expressions.
------ Solution --------------------
$url = 'http://www.okooo.com/Upload/sohu/table_23.html';
$s = file_get_contents($url);
preg_match_all('#
< table>
#isU', $s, $m);
foreach(array_map('strip_tags', $m[0]) as $r) {
$a = preg_split('/\s+/', $r, -1, PREG_SPLIT_NO_EMPTY);
$res[] = array_chunk(array_slice($a, 0, -1), 3);
}
print_r($res);
echo json_encode($res);
<>
Array
(
[0] => Array
(
[0] => Array
(
[0] => ranking
[1] => Team
[2] => points
)
[1] => Array
(
[0] => 1
[1] => Juventus
[2] => 102.
)
[2] => Array
(
[0] => 2
[1] => Rome
[2] => 85
)
[3] => Array
(
[0] => 3
[1] => Naples
[2] => 78
)
[4] => Array
(
[0] => 4
[1] => Florence
[2] => 65
)
[5] => Array
(
[0] => 5
[1] => Milan
[2] => 60
)
[6] => Array
(
[0] => 6
[1] => Parma
[2] => 58