Capture text created by HTML

For questions about Gambas web tools.
Post Reply
User avatar
cogier
Site Admin
Posts: 1179
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Capture text created by HTML

Post by cogier »

I want to capture the text created by a web page.

Here is the page I am looking at http://www.metoffice.gov.gg/livedata.html

The data I want is things like the temperature, wind speed etc. The HTML does not seem to contain any of the displayed data.

I have looked at WebView which displays the page perfectly, I just can't see how to get at the displayed data.
User avatar
thatbruce
Posts: 249
Joined: Saturday 4th September 2021 11:29pm

Re: Capture text created by HTML

Post by thatbruce »

It looks like the data is is two frames not in the main page html
hth
b
User avatar
BruceSteers
Posts: 1972
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Capture text created by HTML

Post by BruceSteers »

Yep , what he said.

it's here..

Code: Select all

<iframe id="temp"
src="http://www.metoffice.gov.gg/met/PA50.html" height ="100%" width ="100%" frameborder="0" scrolling="no" allowtransparency="true" background="none">
</iframe>


</div>
<div class="Live1">
    <iframe id="wind"
src="http://www.metoffice.gov.gg/met/wind2.html" height ="100%" width="100%" frameborder="0" scrolling="no">
</iframe>
so you want to load
http://www.metoffice.gov.gg/met/PA50.html
and
http://www.metoffice.gov.gg/met/wind2.html

then extract the data from the tables

wind2.html looks like this..

Code: Select all

<html><META HTTP-EQUIV=REFRESH CONTENT=30; URL=http://wind2.html><link href="stylewind.css" type="text/css" rel="stylesheet"><body leftmargin=15><div align=center><center><table><tr><td width=224 height=150 align=center><div align=left><table border=0><tr><td width=219 height=50><font size=4>&nbsp;Mean Direction (°T)</font></td></tr><tr><td width=219 height=50><font size=4>&nbsp;Mean Wind Speed (knots)</font></td></tr><tr><td width=219 height=50><font size=4>&nbsp;10 min. Highest Gust (knots)</font></td></tr><tr><td width=219 height=50><font size=4>&nbsp;60 min. Highest Gust (knots)</font></td></tr></table></div></td><td width=118 height=150 align=center><div align=center><center><table border=0 align=left><tr><td height=50 align=center valign=middle width=47><font size=4>340</font></td><td width=60 height=50 align=center valign=middle><font size=3>NNW</font></td></tr><tr><td width=47 height=50 align=center valign=middle><font size=4>6</font></td><td width=60 height=50 align=center valign=middle>force 2</td></tr><tr><td width=47 height=50 align=center valign=middle><font size=4>8</font></td><td width=60 height=50 align=center valign=middle><font size=3>9 mph</font></td></tr><tr><td width=47 height=50 align=center valign=middle><font size=4>8</font></td><td width=60 height=50 align=center valign=middle><font size=3>9 mph</font></td></tr></table></center></div></td></tr></table></center></div><p align=center><font size=3>Updated: 11:48GMT  Sunday 29 December  2024</font></p></body></html>
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1179
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Capture text created by HTML

Post by cogier »

Well done Bruce, you're a star! I'll have a go at that. :D
User avatar
BruceSteers
Posts: 1972
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Capture text created by HTML

Post by BruceSteers »

I has a little play and did this for wind2.html

it's only issue it the "degrees" sign in "Mean Direction (°T)" i could not convert that.

it makes a String[][] array
[title, data1, data2]
[title, data1, data2]
Attachments
Untitled.png
Untitled.png (65.47 KiB) Viewed 1907 times
_aa-0.0.1.tar.gz
(8.01 KiB) Downloaded 141 times
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1179
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Capture text created by HTML

Post by cogier »

Thanks for the program. I cheated a bit on the HTML clean up by shelling to html2text. Here is my effort so far. VERY early days....

Image
GsyWeather-0.0.1.tar.gz
(8.04 KiB) Downloaded 158 times
Post Reply