开发者

DOMDocument xpath query cut off withing a specific timeframe ?

开发者 https://www.devze.com 2023-04-04 10:18 出处:网络
is there a way to cut of the query and return back the results.. preset time to take to get all images from the given url .. i.e. query half of the webpage ? or job time not greater than 5 seconds, so

is there a way to cut of the query and return back the results.. preset time to take to get all images from the given url .. i.e. query half of the webpage ? or job time not greater than 5 seconds, so therefore, it will get everything it can in 5 开发者_StackOverflow中文版seconds.....

$xpath = new DOMXPath( $htmlget);
       $nodelist = $xpath->query( "//img/@src" );


You can evaluate separately any of the following XPath expressions one by one, and stop this process whenever a timer expires or other criterion is satisfied:

(//img/@src)[1]
(//img/@src)[2]
(//img/@src)[3]
...............
(//img/@src)[$N]

This can probably be speeded-up by chunking:

(//img/@src)[position() < 100]
(//img/@src)[position() >= 100 and position() < 200]
...............
(//img/@src)[position() >= 100*$N and position() < 200*$N]
0

精彩评论

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

关注公众号