且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在php中获取html的一部分

更新时间:2023-02-23 14:13:00

If the server supports it, you can make a range request.

Add, to your HTTP request headers:

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Range: 0-1500',
    ));

… to get the first 1500 bytes, which may or may not be the first ten lines, depending on how long the lines are.

The problem with this (aside from possible lack of support by the server) is that you need to know which bytes in the document you want and then you have to extract the data from a partial HTML instead of a complete HTML document.