title: Parse same data from different HTML structures
body: <p>I want to parse receipts to find their total sum. The receipts come in as HTML. But receipts come from different companies, so have different HTML structures. E.g. it can be (those are real life examples):</p>
  
  <p>Company 1: Inside span</p>
  
  <pre><code>&lt;span style="font-size: small;"&gt;
    Amount: $17.85USD Status: Paid&lt;br&gt;Transaction #: 1&lt;br&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>Company 2: one tr in a table</p>
  
  <pre><code>&lt;tr&gt;
    &lt;td style="height:17px; color:black;"&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
    &lt;td style="text-align:right; color:black;"&gt;&lt;strong&gt;15.90€&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Company 3: table inside td from outer table</p>
  
  <pre><code>                 &lt;td style="border: 0;border-collapse: collapse;margin: 0;padding: 0;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;width: 472px;"&gt;
                      &lt;table style="border: 0;border-collapse: collapse;margin: 0;padding: 0;width: 100%;"&gt;
                        &lt;tbody&gt;
                        &lt;tr&gt;
                          &lt;td style="border: 0;border-collapse: collapse;margin: 0;padding: 0;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;" valign="top"&gt;
                            &lt;table style="border: 0;border-collapse: collapse;margin: 0;padding: 0;"&gt;
                              &lt;tbody&gt;
                              &lt;tr&gt;
                                &lt;td style="border: 0;border-collapse: collapse;margin: 0;padding: 0;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Ubuntu, sans-serif;mso-line-height-rule: exactly;vertical-align: middle;color: #8898aa;font-size: 12px;line-height: 16px;white-space: nowrap;font-weight: bold;text-transform: uppercase;"&gt;
                                      Amount paid
                                &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                &lt;td style="border: 0;border-collapse: collapse;margin: 0;padding: 0;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Ubuntu, sans-serif;mso-line-height-rule: exactly;vertical-align: middle;color: #525f7f;font-size: 15px;line-height: 24px;white-space: nowrap;"&gt;
                                      £4.50
                                &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;/tbody&gt;
                            &lt;/table&gt;
                          &lt;/td&gt;
  
  </code></pre>
  
  <p>How would you create an algorithm that would be the most future-proof to parse new receipts from other companies:</p>
  
  <ul>
  <li>Algorithm with a lot of hardcoded paths (tr, table in td, span, p, a lot of if/thens), hardcoding new paths as we find new possibilities?</li>
  <li>Would a machine learning job be suitable here?</li>
  </ul>
  
  <p>Edit: in the HTML, I only show the total sum, but there can be multiple fields with money amounts. I only want to fetch the total sum. Note that it's not always the largest sum on the page, as there might be discounts.</p>