U
U
Us592019-11-06 19:45:41
Parsing
Us59, 2019-11-06 19:45:41

How do you look at such an implementation?

Task: Combine information from 2 or 3 different queries in order to eventually collect HTML code from this information and write it to the database.
There are 2-3 sites that I have to make requests to, different sites give different information, sites respond through the callback option, i.e. - sent a request and you need to accept the answer on my side, all I do is.
The problem is that call backs come at different times and with different separate requests, so when 1 answer came, I immediately have to write it down somewhere, the same with other requests, but in the end the task is to combine everything into one.
As a result, this is what I came up with:
We sent 3 requests and wait, as soon as the answer came - we create a file with the following name:$order_number - website1
$order_number - website2
$order_number - website3
Thus, we have 3 files with different results, and every time a callback comes, we will check if there are 2 other files, if so, then it will be possible to pull out all the information from 3 files at once and use it to create HTML code and immediately write it to A DB, and files which created - to delete.
========
Or maybe somehow create 1 file, but at the same time write the results from 3 sites into it and each time check before recording how many answers have already come in it, if out of 3 answers 2 came and the script wants to record the last answer, then you can immediately pull out 2 results and compose HTML.
PS I think to store in a file via json so that later it would be convenient to pull out and substitute the necessary data in the right place.
===============
Or maybe there are easier and more convenient options? To clarify, I'll say - it can simultaneously perform 50-100 requests.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question