From c26eeb7fb74886d0d003c63bb97e8f396cf05ccc Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Tue, 20 Jun 2017 21:58:46 +0100 Subject: Initial import --- graphs.php | 40 ++++ graphs.phps | 1 + index.php | 90 ++++++++ index.phps | 1 + rain.png | 6 + temp.png | 6 + test.html | 683 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ time-index.txt | 1 + uv.png | 6 + wind.png | 6 + 10 files changed, 840 insertions(+) create mode 100644 graphs.php create mode 120000 graphs.phps create mode 100644 index.php create mode 120000 index.phps create mode 100644 rain.png create mode 100644 temp.png create mode 100644 test.html create mode 100644 time-index.txt create mode 100644 uv.png create mode 100644 wind.png diff --git a/graphs.php b/graphs.php new file mode 100644 index 0000000..981b107 --- /dev/null +++ b/graphs.php @@ -0,0 +1,40 @@ + + + + + + + + +Jersey Weather - Graphs + + + + + +Forecasts | Graphs

\n\n"; + +echo "

This page is currently slow - image caching coming soon.

\n\n"; + +echo "

Temperature / Rainfall

\n\n"; + +file_put_contents("temp.png", file_get_contents("http://data.gov.je/JerseyMet/Town/internet.Temperature.png")); +file_put_contents("rain.png", file_get_contents("http://data.gov.je/JerseyMet/Town/internet.Rainfall.png")); + +echo "

\"Temperature\" \"Rainfall\"

"; + +echo "

UV index / Wind

\n\n"; + +file_put_contents("uv.png", file_get_contents("http://data.gov.je/JerseyMet/Town/internet.UV.png")); +file_put_contents("wind.png", file_get_contents("http://data.gov.je/JerseyMet/Town/internet.Wind.png")); + +echo "

\"UV \"Wind\"

"; + + +?> + + + + diff --git a/graphs.phps b/graphs.phps new file mode 120000 index 0000000..a07634e --- /dev/null +++ b/graphs.phps @@ -0,0 +1 @@ +graphs.php \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..a9f4db2 --- /dev/null +++ b/index.php @@ -0,0 +1,90 @@ + + + + + + + + +loadHTML(file_get_contents("http://www.gov.je/weather/Pages/Jersey-Forecast.aspx")); + +$divs = $dom->getElementsByTagName("div"); + +$day = 0; + +$valid = array(); +$temp = array(); +$misc = array(); + +foreach ($divs as $div) { + if ($day > 2) { + break; + } + + foreach ($div->attributes as $attr) { + if ($attr->nodeValue == "forecastValid") { + array_push($valid, $div->nodeValue); + $day++; + } + + if ($attr->nodeValue == "forecastText" || $attr->nodeValue == "forecastText last") { + array_push($misc, $div->nodeValue); + } + + if ($attr->nodeValue == "main") { + $spans = $div->getElementsByTagName("span"); + foreach ($spans as $span) { + foreach ($span->attributes as $sattr) { + if ($sattr->nodeValue == "temp" || $sattr->nodeValue == "currentc") { + array_push($temp, $span->nodeValue); + } + } + } + } + } + +} + +// Replace newlines with spaces, and strip multiple spaces +for ($i = 0; $i < count($misc); $i++) { + $misc[$i] = preg_replace("/[\r\n]+/", " ", $misc[$i]); + $misc[$i] = preg_replace("/\s+/", " ", $misc[$i]); +} + +for ($i = 0; $i < count($temp); $i++) { +// $temp[$i] = str_replace("°", "°", $temp[$i]); +} + +echo "Max $temp[0], Min $temp[1], Cur $temp[2], $misc[0]\n\n"; +echo "\n\n"; +echo "\n\n"; + +echo "

Forecasts | Graphs

\n\n"; + +echo "

Today

\n\n"; +echo "

$valid[0]

\n"; +echo "Max: $temp[0], Min: $temp[1], Current: $temp[2]

\n"; +echo "Summary: $misc[0]

\n"; +echo "Visibility: $misc[1]

\n"; +echo "Wind: $misc[2]

\n"; +echo "Sea state: $misc[3]

\n\n"; + +echo "

Tomorrow

\n\n"; +echo "

$valid[1]

\n"; +echo "Max: $temp[3], Min: $temp[4]

\n"; +echo "Summary: $misc[4]

\n"; +echo "Wind: $misc[5]

"; + +?> + + + + diff --git a/index.phps b/index.phps new file mode 120000 index 0000000..0012f7d --- /dev/null +++ b/index.phps @@ -0,0 +1 @@ +index.php \ No newline at end of file diff --git a/rain.png b/rain.png new file mode 100644 index 0000000..f086245 --- /dev/null +++ b/rain.png @@ -0,0 +1,6 @@ + + + Channel Islands weather images can be found at + http://www.gov.je/weather + + \ No newline at end of file diff --git a/temp.png b/temp.png new file mode 100644 index 0000000..f086245 --- /dev/null +++ b/temp.png @@ -0,0 +1,6 @@ + + + Channel Islands weather images can be found at + http://www.gov.je/weather + + \ No newline at end of file diff --git a/test.html b/test.html new file mode 100644 index 0000000..bc85c71 --- /dev/null +++ b/test.html @@ -0,0 +1,683 @@ + + + + + + + + Jersey weather forecast + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to main content + Skip to accessibility + +
+ +
+ This website is not compatible with your web browser. You should install a newer browser. If you live in Jersey and need help upgrading call the States of Jersey web team on 440099. +
+ +
+
+
+
+ + gov.je + +

L'înformâtion et les sèrvices publyis pouor I'Île dé Jèrri

+ +
+
+ + + +
+
+ +
+
+ + + + + + + + + +
+
+ + + + +
+ + + + + + + + + +
+ + +
+ +
+
+ + + +
+
+ + +
+ + + + + + + + + +

Jersey weather forecast issued 5 Feb 2015 15:15

+ + + + + + +
+ +
Today
Sleet showers
6°C
20 mph Northeast + F5
Sleet showers
Forecast valid from 4 pm today to 6 am tomorrow
Max6°CMin0°C
Current5.3°C
Fair or cloudy with scattered sleet or snow +showers. Perhaps some icy surfaces.
+ UV Index: 1
Visibility
Good, occasionally moderate to poor in +showers.
20 mph Northeast + F5
Northeast moderate F4 to fresh F5, increasing +fresh F5 to strong F6 during the afternoon, occasionally +strong F7 and gusty near showers.
Sea state
Moderate to rather +rough.
Friday
Fair with sunny periods
5°C
26 mph NortheastF6
Fair with sunny periods
Forecast valid from 6 am Friday to 6 am Saturday
Max5°CMin1°C
Fair or sunny periods. Isolated showers at +first.
UV Index: 1
26 mph Northeast + F6
Northeast strong F6 to 7 with gusts to +50mph, decreasing fresh F5 to strong F6 +overnight.
Saturday
Fair with sunny periods
6°C
20 mph NortheastF5
Fair with sunny periods
+ Forecast valid 6 am to 6 pm Saturday
Max6°C
Fair with sunny periods
UV Index: 1
20 mph Northeast + F5
Northeast F5
Sunday
Fair with sunny periods
6°C
15 mph NortheastF4
Fair with sunny periods
+ Forecast valid 6 am to 6 pm Sunday
Max6°C
Fair with sunny periods
UV Index: 1
15 mph Northeast + F4
Northeast F4
Monday
Cloudy
6°C
15 mph NorthF4
Cloudy
+ Forecast valid 6 am to 6 pm Monday
Max6°C
Cloudy
UV Index: 1
15 mph North + F4
North F4
Tuesday
Cloudy
5°C
15 mph East NortheastF4
Cloudy
+ Forecast valid 6 am to 6 pm Tuesday
Max5°C
Cloudy
UV Index: 1
15 mph East Northeast + F4
East Northeast F4
+ +

Settings

Wind speed Beaufort forceTemperature °Celsius
+
+
+
+ Wind speed +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + +
+
+
+
+
+ Temperature +
    +
  • + +
  • +
  • + +
  • +
+
+
+ +
+ + + + +
+ +
+ +
+

​​If you prefer a text-only forecast, + m.gov.je​ has a layout ideal for ​your smartphone.​

+
+
+
+ + + + + + + + + + + +
+ + + + + +
+ + +
+ + +
+ +
+ +
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + diff --git a/time-index.txt b/time-index.txt new file mode 100644 index 0000000..9267f28 --- /dev/null +++ b/time-index.txt @@ -0,0 +1 @@ +1497992187 \ No newline at end of file diff --git a/uv.png b/uv.png new file mode 100644 index 0000000..f086245 --- /dev/null +++ b/uv.png @@ -0,0 +1,6 @@ + + + Channel Islands weather images can be found at + http://www.gov.je/weather + + \ No newline at end of file diff --git a/wind.png b/wind.png new file mode 100644 index 0000000..f086245 --- /dev/null +++ b/wind.png @@ -0,0 +1,6 @@ + + + Channel Islands weather images can be found at + http://www.gov.je/weather + + \ No newline at end of file -- cgit v1.2.3