开发者

Getting the cURL stream in PHP

  1. If I run curl_exec with no options, the fetched page开发者_运维百科 gets output on php's standard output (the html page being served back).

  2. If I run it with the RETURNTRANSFER option set, I can get the whole page in a variable.

How can I get a stream, that I can then manually parse?

In case 1, I cannot access the data to parse it and in case 2, I need to wait until it is fully downloaded before starting to parse it. I would like something similar to fopen() and fread() where fread($curl_handle, 1000) would return as soon as the first 1000 bytes have been read, and the second call would be return after 2000 bytes have been read, etc.


You might be interested by this answer I gave some time ago : I explained and gave an example of using stream wrappers with curl, to be able to work with the data while it's being fetched -- which seems to be what you want to do.

It's probably not an exact answer to your question, but it could be what you needed to start implementing a solution ;-)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜