R
R
ree4i2015-10-01 13:02:33
PHP
ree4i, 2015-10-01 13:02:33

jquery counter when php parsing to database?

Please advise. I am writing a site parser with a large number of pages, the parser works smoothly.
I want to make some kind of visual counter, i.e. so that it displays the number of pages passed.
I'm thinking of doing it through a cycle - i.e. in a loop I send ajax requests and when I receive a response, I update a certain div with a number.
When the pages run out (php-parser can understand this) - I give the answer to fulfill the condition.

Criticize the thought please. I worked a little with JS, maybe I don’t think there.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
6
65536, 2015-10-01
@ree4i

it is possible to save the current progress to some file in each iteration of the parser. Ajax to knock on a separate script that will read this file and return the value to the browser. the main thing in this separate script is not to use the php session mechanism if it is used in the parser. otherwise, it will queue up until the parser finishes

A
AlikDex, 2015-10-01
@AlikDex

I worked out the following scheme for myself:
1 pass, we parse all the pages for posts, urls to the database, a muscle with a name and status. Usually the post url format is static and does not change. Therefore, so. What gives: well, firstly, you know how many pages you need to parse, and secondly, you can use counters.
Next, we make a cron that independently works in 1 thread or in several (curl) by pulling the post url from the base and setting statuses as it is processed. And the second script that displays statistics (how much is left, how much is in the queue, how much is in progress and which ones, with links. Errors, etc. in percentages and just numbers)
At first, the bar made progress on jkveri, using Ajax, it made a selection of the number of pages for parsing and already parsed. But now I removed it, because I don’t care) once a day you will see how the process is going and that’s it. If 10 consecutive errors - notification by mail and stop script.
Here.

A
Alexander Kubintsev, 2015-10-01
@akubintsev

I experimented in my time with websockets for such a case https://github.com/kryoz/homer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question