Ralph, can you help with a problem relating to this chunk of HTML please?
I found my place in the tree by finding all the <h2 lines, selecting the
one for area7, then selecting the parent with
section = area_lists[13].parent, which begins
<section aria-labelled by.....
I need to find the value of the class attribute, which could be
"marine-card" or "marine-card warning" but
print(section.contents) starts with the <h2 line, and
print(section.contents[0] prints only a blank line.
I tried converting the content to a list of lines, but again, it started
with the <h2 line.
Thanks for your help.
Graeme
On 13/05/2026 14:41, Ralph Corderoy wrote:
Hi Graeme,
https://weather.metoffice.gov.uk/specialist-forecasts/coast-and-sea/inshore-waters-forecast
Look particularly in area-labelledby area7
class="card-content"
class=forecast-block"
etc.
Looking at the HTML, as soon as you click on a lower level tag,
the == $0 disappears
I'm not sure what clicking you mean, but the <section> for 'area7' looks
filled out in the HTML returned by the web server to me.
$ curl -sSg
https://weather.metoffice.gov.uk/specialist-forecasts/coast-and-sea/inshore-waters-forecast
|
sed -rn '/labelledby.*\<area7\>/,/<\/section>/p'
<section aria-labelledby="area7" id="inshore-waters-7" class="marine-card warning"
data-value="inshore-waters-7">
<h2 id="area7" class="card-name">Selsey Bill to Lyme Regis (7)</h2>
<div class="card-content">
<p>Strong winds are forecast</p>
<div class="forecast-block">
<h3>24 hour forecast:</h3>
<div class="forecast-info">
<dl>
<dt>Wind</dt>
<dd>West veering northwest 5 or 6, occasionally 7 at first, then decreasing 4 at
times later.</dd>
<dt>Sea state</dt>
<dd>Slight or moderate.</dd>
<dt>Weather</dt>
<dd>Showers, thundery at first.</dd>
<dt>Visibility</dt>
<dd>Good, occasionally poor at first.</dd>
</dl>
</div>
</div>
<div class="outlook-block">
<h3>Outlook for the following 24 hours:</h3>
<div class="forecast-info">
<dl>
<dt>Wind</dt>
<dd>North or northwest 3 to 5.</dd>
<dt>Sea state</dt>
<dd>Slight, occasionally smooth later.</dd>
<dt>Weather</dt>
<dd>Showers, thundery at first.</dd>
<dt>Visibility</dt>
<dd>Good, occasionally poor at first.</dd>
</dl>
</div>
</div>
</div>
</section>
$
--
Next meeting: Online, Jitsi, Tuesday, 2026-06-02 20:00
Check to whom you are replying
Meetings, mailing list, IRC, ... https://dorset.lug.org.uk
New thread, don't hijack: mailto:[email protected]