N
N
nethole7412021-03-17 12:59:15
PHP
nethole741, 2021-03-17 12:59:15

API data parsing. How to get a lot of data?

Hello, such question as it is possible to receive the data in large volume with a step. It is necessary to get about 130,000 values, the exact number may not be known, only 1000 values ​​can be obtained at a time. It is necessary that he then starts from 1000 to 2000 and so on to further obtain the id. Is it possible to do this with php? Because timings will interfere with judging. Here is the code

$file = $api->getFilesList($a[$i], 1000, 0, ['date_created'=>-1]);

Here is an array example
Array
(
    [status] => success
    [code] => 200
    [files] => Array
        (
            [0] => Array
                (
                    [id] => 9644cf5ebd85e
                    [name] => name1.mp4
                    [is_available] => 1
                    [is_folder] => 
                    [date_created] => 2021-03-14 23:53:42
                    [size] => 347925848
                    [md5] => b2b660612c87d693983ce64d4ce28b76
                )

            [1] => Array
                (
                    [id] => 8659059dbce71
                    [name] => name2.mp4
                    [is_available] => 1
                    [is_folder] => 
                    [date_created] => 2021-03-14 23:53:01
                    [size] => 292391969
                    [md5] => 83132a8d3f55ccb0c90fa19312f02688
                )

            [2] => Array
                (
                    [id] => 8b374ca87ad21
                    [name] => name3.mp4
                    [is_available] => 1
                    [is_folder] => 
                    [date_created] => 2021-03-10 01:08:45
                    [size] => 602223831
                    [md5] => d025abafde70d46dface6bdd14ca913e
                )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nethole741, 2021-03-18
@nethole741

Found a solution to change the offset parameter in api

$v = 0;
while (true) {
    	$file = $api->getFilesList($a[$i], 1000, $v*1000, ['date_created'=>-1]);
    	if (count($file['files']) == 0) {
    		break;
    	}
    	$v++;
}

N
nokimaro, 2021-03-17
@nokimaro

If you need to run a long-running script - run it via CLI
https://www.php.net/manual/ru/features.commandline...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question