awk to extract value after keyword in html

Using awk to extract value after a keyword in an html , and store in ts . The awk does execute but ts is empty. I use the tag as a delimiter and the keyword as a pattern, but there probably is a better way. Thank you :).

file

<html><head><title>xxxxxx xxxxx</title><style type="text/css">
 @media screen {
  div.summary {
    width: 18em;
    position:fixed;
    top: 3em;
    margin:1em 0 0 1em;
  }
...
...
...
<th>Measure</th><th>Value</th></tr></thead><tbody><tr><td>Filename</td><td>xxxxx</td></tr><tr><td>File type</td><td>Conventional base calls</td></tr><tr><td>Encoding</td><td>Sanger / Illumina 1.9</td></tr><tr><td>Total Sequences</td><td>49531132</td></tr><tr><td>Sequences flagged as poor quality</td><td>0</td></tr><tr><td>Sequence length</td><td>151</td></tr><tr><td>%GC</td><td>51</td></tr></tbody></table></div><div class="module"><h2 id="M1"><img
...
...
...

awk

ts=$(awk -F "[/tr><tr><td></td>]" '/Total Sequences/{print $2}' file)
echo $ts

desired

$ts=49531132

Hi

awk -F'Total Sequences[^0-9]*' '/Total Sequences/ {sub("[^0-9].*", "", $2); print $2}'

--- Post updated at 23:03 ---

sed -n 's/.*Total Sequences[^0-9]*\([0-9]*\).*/\1/p' file

--- Post updated at 23:13 ---

awk -F'</td><td>|</td></tr><tr><td>' '/Total Sequences/ {print $8}' file
1 Like

Try also

awk 'match ($0, /Total Sequences<\/td><td>[^<]*/) {print substr ($0, RSTART+24, RLENGTH-24)}' file
49531132
1 Like

Try:

awk '$2=="Total Sequences"{n=-3} ++n==0{print "$ts=" $2}' RS=\< FS=\> file
1 Like

Thank you all :).