Home > Blockchain >  Import table from html into google sheets
Import table from html into google sheets

Time:09-03

I have the following table element from a website.

Using this formula only extracts the 1st td ie class='TTRow_left' I want to extract both and in a google sheet

Formula: '''IMPORTHTML("https://www.bsesme.com/","table",6)'''

Html: '''

No. of Companies Listed on SME till Date 386
          <tr>
      <td  style="height:22px;" width="230px">Mkt Cap of Cos. Listed on SME till Date (Rs.Cr.)</td>
      <td  style="height:22px;" id="MCL">58,225.56</td>
      </tr>
          <tr>
      <td  style="height:22px;" width="230px">Total Amount of Money Raised till Date (Rs. Cr.)</td>
      <td  style="height:22px;" id="Td13">4,132.16</td>
            
      </tr>


      <tr>
      <td  style="height:22px;" width="230px">No. of Companies Migrated to Main Board</td>
      <td  style="height:22px;" id="MB"><a href="markets/Migrated.aspx" target="_blank" >150</a></td>
      </tr>
      <tr>
      <td  style="height:22px;" width="230px">No. of Companies Listed as of Date </td>
      <td  style="height:22px;" id="CL"><a href="markets/SME_streamer.aspx" target="_blank" > 236</a></td>
      </tr>
       <tr>
      <td  style="height:22px;">No. of Companies Suspended</td>
      <td  style="height:22px;" id="CS">32</td>
      </tr>
       <tr>
      <td  style="height:22px;">No. of Companies Eligible for Trading</td>
      <td  style="height:22px;" id="CET"><a href="markets/SME_streamer.aspx" target="_blank" >201</a></td>
      </tr>
       <tr>
      <td  style="height:22px;">No. of Companies Traded</td>
      <td  style="height:22px;" id="CT"><a href="markets/MarketGnerLser.aspx?flag=T" target="_blank" >110</a></td>
      </tr>
        <tr>
      <td  style="height:22px;">Advances/ Declines/ Unchanged</td>
      <td  style="height:22px;" id="Adv"><a href="markets/AdvDecCircutSumm.aspx?pgid=AD" target="_blank" >73</a>/&nbsp;<a href="markets/AdvDecCircutSumm.aspx?pgid=AD" target="_blank" >32</a>/&nbsp;<a href="markets/AdvDecCircutSumm.aspx?pgid=AD" target="_blank" >5</a></td>
      </tr>
       <tr>
      <td  style="height:22px;">Mkt Cap of BSE SME Listed Cos. (Rs.Cr.)</td>
      <td  style="height:22px;" id="Dec">15,095.93</td>
      </tr>
     
              <!--<tr>
      <td  style="height:22px;" width="230px">No. of SME companies migrated to main board</td>
      <td  style="height:22px;" >3</td>
      </tr>-->

      </tbody></table>
    </td>
    </tr>
    </tbody></table>

'''

CodePudding user response:

There is a way, You could extract that data with Google Apps Script - i.e. writing a function that reads the values (those are returned by a separated request).

You need to make a request to this url - which is the one that loads the data:

enter image description here

As you can see when JavaScript is disabled the content in the page is not displayed however the Table content TTRow_left is hard coded that's why the function is able to get this information from the web page:

td style="height:22px;" width="230px">No. of Companies Listed on SME till Date'

You will notice that TTRow_right is not displayed therefore the function won't be able to scrap data from it.

  • Related