V
V
Vadim Timoshenko2020-05-06 19:59:00
PHP
Vadim Timoshenko, 2020-05-06 19:59:00

How to divide parsing into stages?

Wrote a parser. Takes a link from a .csv file, looks for other links, writes everything to a new .csv file.

There are about 200 links in the initial file. As a result, the script works for a long time. But it cuts off with a 504 error. Although I increased the script's running time to infinity in php.ini.

Question. How to make the parser parse step by step. So that I can see that the first link was successfully parsed. And so that there is no 504 error? Ajax if I can use anything. I understand how to receive data in the opposite direction and display it on the screen.

The question is - how to make the .php file of the parser run every time anew?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2020-05-06
@PbI6A_KuT

504 is gateway time-out - it means that there is some server in front of your php that still has a timeout and stops execution by this timeout.
In any case, running any parsing scripts through the browser is a very bad idea.
Log in through the console and run as a console script.

A
Alexander Shvedov, 2020-05-06
@constintmid

Use try catch depending on which version of php you are using catch errors with Exceptioon or Throwable When you catch an error, handle it there you can restart everything very easily and you don't have to fuss.
Catch the error write how to handle it apparently you will not have such a large pool of them

H
hack504, 2020-05-06
@hack504

It seems to be possible to 'loop' in a loop using ob_start() and ob_get_clean().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question