开发者

HOWTO extract specific text from HTML/XML ,using cURL and HTTP

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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜