Getting cURL stream in PHP

  • If I run curl_exec without parameters, the selected page will be output to standard php output (the html page will be returned).

  • If I run it using the RETURNTRANSFER parameter, I can get the whole page in a variable.

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

In case 1, I can’t access the data for analysis, and in case 2 I need to wait until it is fully loaded before starting to analyze it. I would like something similar to fopen() and fread() , where fread($curl_handle, 1000) will return as soon as the first 1000 bytes are read, and the second call will be returned after reading 2000 bytes, etc.

+4
source share
1 answer

You may be interested in this answer, which I gave some time ago : I explained and gave an example of using flow wrappers with curl to be able to work with data when it is retrieved - which seems to be what you want to do.

This is probably not the exact answer to your question, but it may be what you need to start implementing the solution; -)

+5
source

All Articles