L
L
Loopst2019-11-25 16:00:30
PHP
Loopst, 2019-11-25 16:00:30

How to copy html tables from whole site and write them to a file?

There is a site on which there are necessary tables. We need to take a link to a page, a title from this page, an html table and write it to a file. And so with the whole site.
The title of this plan is:

<h2 class="vinous-header text-center">Теплообменники M18 (Sesino)</h2>

A table of such a plan:
Table
<table frame="VOID" cols="6" rules="NONE" class="contenttable" cellspacing="0" border="0"> 
              <colgroup><col width="139"><col width="147"><col width="161"><col width="161"><col width="86"><col width="86"></colgroup>
               
              <tbody> 
                <tr class="table-th tr-even"> 
                  <td width="139" valign="MIDDLE" height="32" align="CENTER"><b>Наименование</b></td>
                   
                  <td width="147" valign="MIDDLE" align="CENTER"><b>Поверхность (м<sup>2</sup>)</b></td>
                   
                  <td width="161" valign="MIDDLE" align="CENTER"><b>Расход (л/мин)</b></td>
                   
                  <td width="161" valign="MIDDLE" align="CENTER"><b>Мощность охлаждения (кВт/<span style="font-size: 13.3333px;"><sup>o</sup></span>С)</b></td>
                   
                  <td width="86" valign="MIDDLE" align="CENTER"><b>Вес (кг)</b></td>
                   
                  <td width="86" valign="MIDDLE" align="CENTER"><b>Размер А (мм)</b></td>
                   </tr>
                 
                <tr class="table-th-second tr-odd"> 
                  <td valign="MIDDLE" height="17" align="CENTER">M18-10</td>
                   
                  <td sdval="0,195" sdnum="1049;0;0,000" valign="MIDDLE" align="CENTER">0,195</td>
                   
                  <td sdnum="1049;0;0" valign="MIDDLE" align="CENTER">10 – 30</td>
                   
                  <td valign="MIDDLE" align="CENTER">0,09 – 0,27</td>
                   
                  <td sdval="2,5" sdnum="1049;0;0,0" valign="MIDDLE" align="CENTER">2,5</td>
                   
                  <td sdval="28" sdnum="1049;0;0" valign="MIDDLE" align="CENTER">28</td>
                   </tr>
                 
                <tr class="tr-even"> 
                  <td valign="MIDDLE" height="17" align="CENTER">M18-20</td>
                   
                  <td sdval="0,39" sdnum="1049;0;0,000" valign="MIDDLE" align="CENTER">0,390</td>
                   
                  <td sdnum="1049;0;0" valign="MIDDLE" align="CENTER">20 – 60</td>
                   
                  <td valign="MIDDLE" align="CENTER">0,25 – 0,55</td>
                   
                  <td sdval="3,7" sdnum="1049;0;0,0" valign="MIDDLE" align="CENTER">3,7</td>
                   
                  <td sdval="47" sdnum="1049;0;0" valign="MIDDLE" align="CENTER">47</td>
                   </tr>
                 
                <tr class="tr-odd"> 
                  <td valign="MIDDLE" height="17" align="CENTER">M18-30</td>
                   
                  <td sdval="0,585" sdnum="1049;0;0,000" valign="MIDDLE" align="CENTER">0,585</td>
                   
                  <td sdnum="1049;0;0" valign="MIDDLE" align="CENTER">30 – 90</td>
                   
                  <td valign="MIDDLE" align="CENTER">0,45 – 0,83</td>
                   
                  <td sdval="4,8" sdnum="1049;0;0,0" valign="MIDDLE" align="CENTER">4,8</td>
                   
                  <td sdval="66" sdnum="1049;0;0" valign="MIDDLE" align="CENTER">66</td>
                   </tr>
                 
                <tr class="tr-even"> 
                  <td valign="MIDDLE" height="17" align="CENTER">M18-40</td>
                   
                  <td sdval="0,78" sdnum="1049;0;0,000" valign="MIDDLE" align="CENTER">0,780</td>
                   
                  <td sdnum="1049;0;0" valign="MIDDLE" align="CENTER">40 – 120</td>
                   
                  <td valign="MIDDLE" align="CENTER">0,60 – 1,17</td>
                   
                  <td sdval="6" sdnum="1049;0;0,0" valign="MIDDLE" align="CENTER">6,0</td>
                   
                  <td sdval="85" sdnum="1049;0;0" valign="MIDDLE" align="CENTER">85</td>
                   </tr>
                 
                <tr class="tr-odd"> 
                  <td valign="MIDDLE" height="17" align="CENTER">M18-50</td>
                   
                  <td sdval="0,975" sdnum="1049;0;0,000" valign="MIDDLE" align="CENTER">0,975</td>
                   
                  <td sdnum="1049;0;0" valign="MIDDLE" align="CENTER">50 – 150</td>
                   
                  <td valign="MIDDLE" align="CENTER">0,85 – 1,40</td>
                   
                  <td sdval="7,2" sdnum="1049;0;0,0" valign="MIDDLE" align="CENTER">7,2</td>
                   
                  <td sdval="104" sdnum="1049;0;0" valign="MIDDLE" align="CENTER">104</td>
                   </tr>
                 </tbody>
               </table>

The number of rows and columns can vary greatly.
Tell me, please, how can this be done? Some kind of parser, maybe, or something else?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Komarnitsky, 2019-11-25
@romkom

There are libraries with which you can get DOM elements in php using a similar syntax with javascript (jquery).
Here is an example: click

X
xmoonlight, 2019-11-25
@xmoonlight

PHP: curl+regex.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question