BFont f; int displayTemp = 0; int thermo = 0; void setup() { size(320,200); f = loadFont("Meta-Bold.vlw.gz"); } void loop() { background(0); fill(255); textFont(f,64); text(displayTemp + " degrees F",10,58); textFont(f,24); text("click to load current temperature",10,180); stroke(255); fill(200); rect(10,100,thermo*2,20); if (thermo < displayTemp) { thermo++; } line(10,130,210,130); } void mousePressed() { displayTemp = getTemperature("10003"); } int getTemperature(String zip) { //Get all the HTML source code into an array of strings (each line is one element in the array) //String url = "http://wwwa.accuweather.com/adcbin/public/local_index.asp?zipcode=" + zip + "&partner=accuweather"; String url = "loadstrings.php?url=http://wwwa.accuweather.com/adcbin/public/local_index.asp?zipcode=" + zip + "&partner=accuweather"; String[] lines = loadStrings(url); //convert array into one long string String stuff = makeOneLongString(lines); //find the character sequence 'cTmp=' in the html source int beginning = stuff.indexOf("cTmp="); //make a substring starting with characters after "cTmp" -- in effect, deletes beginning of string stuff = stuff.substring(beginning+5,stuff.length()); //find the '&' in the string int end = stuff.indexOf("&"); //make a substring where we only have the temperature value left stuff = stuff.substring(0,end); //remember stuff is a string, but we want it as an integer int temperature = Integer.parseInt(stuff); return temperature; } String makeOneLongString(String[] input) { //start with an empty string and concatenate all lines together String s = ""; for (int i = 0; i < input.length; i++) { s = s + input[i]; } return s; }