here's the BBC RSS feed for Leeds at the moment:

here's the bit that I'm interested in:

(Temperature: 9°C (48°F), Wind Direction: SW, Wind Speed: 40mph, Relative Humidity: 66%, Pressure: 987mB, rising, Visibility: Good)
Unfortunately, all the juicy bit I'm interested in is all in the same XML tag, so I can't use simpleML to all it's useful yummyness.
This causes a little problem with the words I'm using in my script. For example, "sunny" and "sunny intervals" both contain the word "sunny" so my script will see "sunny intervals" as "sunny". If that makes sense. The script I'm using at the moment is based on a script I used in my last project:
//pulling in feed of weather in stornoway
String[] tokens; //array
int counter;
void setup() {
size(100, 100);
//load file and split up words
String[] lines = loadStrings("http://news.bbc.co.uk/weather/forecast/373/ObservationsRSS.rss");
String allText = join(lines, " ");
tokens = splitTokens(allText, " ,.?!:;[]-");
}
//so it's now pulling in that sentence and splitting it up.
void draw() {
background(255);
fill(0);
String s = tokens[counter];
counter = (counter +1) % tokens.length;
//look at the words one at a time please
//is the word there?
if (s.equals("sunny")) {
println("sunny");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("white")) {
println("white cloud");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("grey")) {
println("grey cloud");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("light")) {
println("light rain");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("heavy")) {
println("heavy rain");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("clear")) {
println("clear sky (night)");
noLoop(); //DON'T LOOP IT BAHBEE.
}
}
Now i just need to simpleML it up.
No comments:
Post a Comment