PHP cURL same HTML element -
this question has answer here:
- how parse , process html/xml in php? 27 answers
i want output third element same html element. know how output div
or span
id or class have no idea how output same html element. thought p[1]
doesn't work.
i know there lot of answered questions never explained how output same html element without class
or id
.
website : http://localhost/ <p>example</p> <p>example1</p> <!-- want take 1 --> <p>example2</p> ------------------- php script : <?php $curl = curl_init('http://localhost/'); curl_setopt($curl, curlopt_returntransfer, true); $code3 = curl_exec($curl); curl_close($curl); $code = '/<p>(.*?)<\/p>/s'; $code6= preg_match($code, $code3, $code4); echo $code4[1] ?> /* doesn't work .. php.net doesnt give example hope can me here. advanced ! */
try:
<?php $curl = curl_init('http://justpaste.it/8s5v'); curl_setopt($curl, curlopt_returntransfer, true); $content = curl_exec($curl); curl_close($curl); preg_match_all('/<p>(.+)<\/p>/im', $content, $result); print_r($result); print "selected: " . $result[0][1] . "\n"; ?>
Comments
Post a Comment