所以我正在构建一个短语xml文件的应用程序...它需要使用curl来获取文件。
我正在使用此命令:
curl -L -o /Users/MyName/Desktop/fileName.xml http://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=KPHX&hoursBeforeNow=1
首先,here's a link到他们的api
还有here's some of their examples
当我在浏览器中查看数据服务器URL时,显示正常。
但是当我卷曲它时我得到了这个:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<request_index>548652</request_index>
<data_source name="server" />
<request type="status" />
<errors>
<error>requestType parameter required</error>
</errors>
<warnings>
<warning>Request type not specified, defaulting to status</warning>
<warning>Data source not specified, defaulting to server</warning>
</warnings>
<time_taken_ms>0</time_taken_ms>
<response />
</Response>
而不是我的浏览器中显示的是什么
<?xml version="1.0" encoding="UTF-8"?>
<response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-Schema-instance" version="1.2" xsi:noNamespaceSchemaLocation="http://aviationweather.gov/adds/schema/metar1_2.xsd">
<request_index>550259</request_index>
<data_source name="metars" />
<request type="retrieve" />
<errors />
<warnings />
<time_taken_ms>3</time_taken_ms>
<data num_results="3">
<METAR>
<raw_text>KPHX 120551Z 08007KT 10SM CLR 12/01 A3002 RMK AO2 SLP161 T01170011 10211 20117 58004</raw_text>
<station_id>KPHX</station_id>
<observation_time>2014-01-12T05:51:00Z</observation_time>
<latitude>33.43</latitude>
<longitude>-112.02</longitude>
<temp_c>11.7</temp_c>
<dewpoint_c>1.1</dewpoint_c>
<wind_dir_degrees>80</wind_dir_degrees>
<wind_speed_kt>7</wind_speed_kt>
<visibility_statute_mi>10.0</visibility_statute_mi>
<altim_in_hg>30.02067</altim_in_hg>
<sea_level_pressure_mb>1016.1</sea_level_pressure_mb>
<quality_control_flags>
<auto_station>TRUE</auto_station>
</quality_control_flags>
<sky_condition sky_cover="CLR" />
<flight_category>VFR</flight_category>
<three_hr_pressure_tendency_mb>-0.4</three_hr_pressure_tendency_mb>
<maxT_c>21.1</maxT_c>
<minT_c>11.7</minT_c>
<metar_type>SPECI</metar_type>
<elevation_m>336.0</elevation_m>
</METAR>
<METAR>
<raw_text>KPHX 120451Z 00000KT 10SM CLR 13/01 A3003 RMK AO2 SLP162 T01280006</raw_text>
<station_id>KPHX</station_id>
<observation_time>2014-01-12T04:51:00Z</observation_time>
<latitude>33.43</latitude>
<longitude>-112.02</longitude>
<temp_c>12.8</temp_c>
<dewpoint_c>0.6</dewpoint_c>
<wind_dir_degrees>0</wind_dir_degrees>
<wind_speed_kt>0</wind_speed_kt>
<visibility_statute_mi>10.0</visibility_statute_mi>
<altim_in_hg>30.029528</altim_in_hg>
<sea_level_pressure_mb>1016.2</sea_level_pressure_mb>
<quality_control_flags>
<auto_station>TRUE</auto_station>
</quality_control_flags>
<sky_condition sky_cover="CLR" />
<flight_category>VFR</flight_category>
<metar_type>METAR</metar_type>
<elevation_m>336.0</elevation_m>
</METAR>
<METAR>
<raw_text>KPHX 120351Z 00000KT 10SM CLR 14/01 A3004 RMK AO2 SLP166 T01390006</raw_text>
<station_id>KPHX</station_id>
<observation_time>2014-01-12T03:51:00Z</observation_time>
<latitude>33.43</latitude>
<longitude>-112.02</longitude>
<temp_c>13.9</temp_c>
<dewpoint_c>0.6</dewpoint_c>
<wind_dir_degrees>0</wind_dir_degrees>
<wind_speed_kt>0</wind_speed_kt>
<visibility_statute_mi>10.0</visibility_statute_mi>
<altim_in_hg>30.041338</altim_in_hg>
<sea_level_pressure_mb>1016.6</sea_level_pressure_mb>
<quality_control_flags>
<auto_station>TRUE</auto_station>
</quality_control_flags>
<sky_condition sky_cover="CLR" />
<flight_category>VFR</flight_category>
<metar_type>SPECI</metar_type>
<elevation_m>336.0</elevation_m>
</METAR>
</data>
</response>
对不起,如果这是一篇很长的帖子,只是不是最容易解释的。
答案 0 :(得分:1)
你正在使用的shell是解释&符号。只需引用该URL,您就可以获取该文件。