I successfully downloaded a file from a remote server using cURL and HTTP, but the file includes all the HTML code.
Is there a function in cURL so that I can extract the values I want?
For example, 开发者_如何学CI am getting:
...
<body>
Hello,Manu
</body>
...
But I only want Hello,Manu
.
Thanks in advance,
Manu
try using DOMDocument or any other XML parser.
$doc= new DOMDocument();
$doc->loadHTML($html_content); // result from curl
$xpath= new DOMXPath($doc);
echo $xpath->query('//body')->item(0)->nodeValue;
alternatively for command line you can use
curl 'http://.................' | xpath '//body'
精彩评论