Batch file that extracts weather

March 23, 2012 at 20:30:15
Specs: Windows 7
I need a batch code that can display weather from http://www.weather.gov/xml/current_... on the screen.

See More: Batch file that extracts weather

Report •

#1
March 23, 2012 at 23:50:43
This does it on my computer:

"C:\Program Files\Internet Explorer\iexplore.exe" $http://www.weather.gov/xml/current_obs/KPHL.xml

NOTE: You have to delete the "$". I had to put that there to get the forum editor to accept this.

Were you looking for some other format?


Report •

#2
March 24, 2012 at 08:55:27
The following requires cURL.exe to be found in your %path%:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET url=http://www.weather.gov/xml/current_obs/KPHL.xml
FOR /F "skip=15 tokens=* delims=" %%A IN ('cURL -s --url %url%') DO (
    SET xml_line=%%A
    SET xml_line=!xml_line:"='!
    SET xml_line=!xml_line:^&=and!
    SET xml_line=!xml_line:^<=[!
    SET xml_line=!xml_line:^>=]!
    FOR /F "tokens=2,3 delims=[]" %%B IN ("!xml_line!") DO ECHO %%B = %%C
)
EXIT /B

Output:

location = Philadelphia International Airport, PA
station_id = KPHL
latitude = 39.87
longitude = -75.23
observation_time = Last Updated on Mar 24 2012, 10:54 am EDT
observation_time_rfc822 = Sat, 24 Mar 2012 10:54:00 -0400
weather = Overcast
temperature_string = 60.0 F (15.6 C)
temp_f = 60.0
temp_c = 15.6
relative_humidity = 67
wind_string = East at 9.2 MPH (8 KT)
wind_dir = East
wind_degrees = 80
wind_mph = 9.2
wind_gust_mph = 0.0
wind_kt = 8
wind_gust_kt = 0
pressure_string = 1017.4 mb
pressure_mb = 1017.4
pressure_in = 30.05
dewpoint_string = 48.9 F (9.4 C)
dewpoint_f = 48.9
dewpoint_c = 9.4
windchill_string = 59 F (15 C)
windchill_f = 59
windchill_c = 15
visibility_mi = 10.00
icon_url_base = <a href="http://weather.gov/images/fcicons/" target="_blank">http://weather.gov/images/fcicons/</a>
two_day_history_url = <a href="http://www.weather.gov/data/obhistory/KPHL.html" target="_blank">http://www.weather.gov/data/obhisto...</a>
icon_url_name = ovc.jpg
ob_url = <a href="http://www.weather.gov/data/METAR/KPHL.1.txt" target="_blank">http://www.weather.gov/data/METAR/K...</a>
disclaimer_url = <a href="http://weather.gov/disclaimer.html" target="_blank">http://weather.gov/disclaimer.html</a>
copyright_url = <a href="http://weather.gov/disclaimer.html" target="_blank">http://weather.gov/disclaimer.html</a>
privacy_policy_url = <a href="http://weather.gov/notice.html" target="_blank">http://weather.gov/notice.html</a>

When your only tool is a hammer, every problem looks like a nail.


Report •

#3
March 24, 2012 at 14:27:06
Sorry but i'm new to batch but where can I find cURL.exe.

Report •

Related Solutions

#4
Report •

#5
May 4, 2012 at 16:39:24
why not use the web query function in excel and format it however you want.

Report •

#6
May 4, 2012 at 18:47:24
why not use the web query function in excel and format it however you want.

Would that be considered "batch code", like the OP wanted?

When your only tool is a hammer, every problem looks like a nail.


Report •

Ask Question