반응형
안녕하세요 푸민입니다.
야후 API를 이용해서 날씨정보를 받아올수 있습니다!
나름 정확하니 한번 이용해보세요~
서울지역 결과 XML
<rss xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0">
<channel>
<title>Yahoo! Weather - Seoul, KR</title>
<description>Yahoo! Weather for Seoul, KR</description>
<language>en-us</language>
<lastBuildDate>Wed, 06 Nov 2013 6:00 pm KST</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Seoul" region="" country="South Korea"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"/>
<yweather:wind chill="13" direction="200" speed="19.31"/>
<yweather:atmosphere humidity="82" visibility="4.7" pressure="1015.92" rising="0"/>
<yweather:astronomy sunrise="7:01 am" sunset="5:30 pm"/>
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
</image>
<item>
<title>Conditions for Seoul, KR at 6:00 pm KST</title>
<geo:lat>37.56</geo:lat>
<geo:long>126.98</geo:long>
<pubDate>Wed, 06 Nov 2013 6:00 pm KST</pubDate>
<yweather:condition text="Fog" code="20" temp="13" date="Wed, 06 Nov 2013 6:00 pm KST"/>
<description>
<![CDATA[
<img src="http://l.yimg.com/a/i/us/we/52/20.gif"/><br /> <b>Current Conditions:</b><br /> Fog, 13 C<BR /> <BR /><b>Forecast:</b><BR /> Wed - Showers. High: 16 Low: 12<br /> Thu - Sunny. High: 14 Low: 4<br /> Fri - Mostly Sunny. High: 15 Low: 7<br /> Sat - PM Showers. High: 16 Low: 6<br /> Sun - Sunny. High: 10 Low: 1<br /> <br /> <a href="http://us.rd.yahoo.com/dailynews/rss/weather/Seoul__KR/*http://weather.yahoo.com/forecast/KSXX0037_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/> (provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
]]>
</description>
<yweather:forecast day="Wed" date="6 Nov 2013" low="12" high="16" text="Showers" code="11"/>
<yweather:forecast day="Thu" date="7 Nov 2013" low="4" high="14" text="Sunny" code="32"/>
<yweather:forecast day="Fri" date="8 Nov 2013" low="7" high="15" text="Mostly Sunny" code="34"/>
<yweather:forecast day="Sat" date="9 Nov 2013" low="6" high="16" text="PM Showers" code="39"/>
<yweather:forecast day="Sun" date="10 Nov 2013" low="1" high="10" text="Sunny" code="32"/>
<guid isPermaLink="false">KSXX0037_2013_11_10_7_00_KST</guid>
</item>
</channel>
</rss>
<!--
api62.weather.sg3.yahoo.com Wed Nov 6 09:36:18 PST 2013
-->
이렇게 받아와서 파싱해서 사용하시면 되요!
어떻게 받는지를 한번 알아볼까요?
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text=%22"(찾을지역영문이름)"%22&format=xml
여기에 지역코드를 요청하면 되요!
야후에서 제공하는 woeid라는 코드를 이용해야 날씨정보를 요청할 수 있기 때문입니다.
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text=%22seoul%22&format=xml
즉 이렇게 요청하면 seoul지역에 관한 정보를 가져옵니다!
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="3" yahoo:created="2013-11-06T09:44:47Z" yahoo:lang="en-US">
<results>
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/1132599">
<woeid>1132599</woeid>
<placeTypeName code="7">Town</placeTypeName>
<name>Seoul</name>
<country code="KR" type="Country" woeid="23424868">South Korea</country>
<admin1 code="KR-11" type="Province" woeid="20069923">Seoul</admin1>
<admin2/>
<admin3/>
<locality1 type="Town" woeid="1132599">Seoul</locality1>
<locality2/>
<postal/>
<centroid>
<latitude>37.557121</latitude>
<longitude>126.977379</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>37.421341</latitude>
<longitude>126.768600</longitude>
</southWest>
<northEast>
<latitude>37.692902</latitude>
<longitude>127.186150</longitude>
</northEast>
</boundingBox>
<areaRank>6</areaRank>
<popRank>13</popRank>
<timezone type="Time Zone" woeid="28350854">Asia/Seoul</timezone>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/20069923">
<woeid>20069923</woeid>
<placeTypeName code="8">Province</placeTypeName>
<name>Seoul</name>
<country code="KR" type="Country" woeid="23424868">South Korea</country>
<admin1 code="KR-11" type="Province" woeid="20069923">Seoul</admin1>
<admin2/>
<admin3/>
<locality1/>
<locality2/>
<postal/>
<centroid>
<latitude>37.557121</latitude>
<longitude>126.977379</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>37.421341</latitude>
<longitude>126.768600</longitude>
</southWest>
<northEast>
<latitude>37.692902</latitude>
<longitude>127.186150</longitude>
</northEast>
</boundingBox>
<areaRank>6</areaRank>
<popRank>0</popRank>
<timezone type="Time Zone" woeid="28350854">Asia/Seoul</timezone>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/90238795">
<woeid>90238795</woeid>
<placeTypeName code="20">Point of Interest</placeTypeName>
<name>Seoul</name>
<country code="ES" type="Country" woeid="23424950">Spain</country>
<admin1 code="ES-GA" type="Autonomous Community" woeid="12578036">Galicia</admin1>
<admin2 code="" type="Province" woeid="12602132">Orense</admin2>
<admin3 code="" type="Municipality" woeid="12694913">Ourense</admin3>
<locality1 type="Town" woeid="768888">Orense</locality1>
<locality2/>
<postal/>
<centroid>
<latitude>42.352039</latitude>
<longitude>-7.866350</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>42.351582</latitude>
<longitude>-7.866960</longitude>
</southWest>
<northEast>
<latitude>42.352489</latitude>
<longitude>-7.865730</longitude>
</northEast>
</boundingBox>
<areaRank>0</areaRank>
<popRank>0</popRank>
<timezone type="Time Zone" woeid="56043644">Europe/Madrid</timezone>
</place>
</results>
</query>
<!-- total: 36 -->
<!-- engine4.yql.sg3.yahoo.com -->
이렇게 해당 지역 정보를 내려주네요 ㅎㅎㅎ 너무 많아...;;;;
여튼 woeid 1132599 를 이용해서
http://weather.yahooapis.com/forecastrss?w= 1132599&u=c
여기에 요청을 하면 날씨 정보를 받아옵니다~
문의사항은 sj60414@네이트닷컴과 댓글로 해주세요~
반응형
'Development > Tools' 카테고리의 다른 글
[명령어]한글 2010 대비 워드 명령어 (0) | 2015.08.11 |
---|---|
[GIT] Gitignore 캐시제거하기 (0) | 2015.08.11 |
[GIT] Github Public ssh key 추출하기 (0) | 2015.08.11 |
[GIT] gitignore 추가하기 (0) | 2015.08.09 |
[Tools] 개발에 도움되는 좋은글들~ (0) | 2015.08.08 |
댓글