2021. 11. 11. 11:32ㆍpython
* API (Application Programming Interface)
: 어느 프로그램 기능을 외부 프로그램에서 사용할 수 있도록 만든 것
즉 서로 다른 프로그램이 기능을 공유할 수 있도록 한 것
** Web API
: 웹상의 많은 정보를 공유할 수 있도록 제공하는 것
단점은 해당 제공자의 사정에 의해 변동이 심하다.
` 다음 개발자 센터
` 네이버 개발자 센터
` 구글 개발자 센터
` [그외] https://www.apistore.co.kr/api/apiList.do
API 날씨정보가져오기
전세계날씨제공 API : http://openweathermap.org
1. 회원가입 : 메뉴 > Sign Up > 사용용도 : Education > 대충가입 (무료는 1번에 60번 호출 가능 )
2. 개발자모드 : Sign In > API Keys 에서 내가 발급받은 키 (추가 키 가능)
3. 발급받고 바로 지정 안됨 (시간소요)
#res만 출력한 상태
{"coord":{"lon":126.9778,"lat":37.5683},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":281.78,"feels_like":278.59,"temp_min":279.86,"temp_max":282.84,"pressure":1011,"humidity":53},"visibility":10000,"wind":{"speed":6.17,"deg":360},"clouds":{"all":0},"dt":1636596967,"sys":{"type":1,"id":8105,"country":"KR","sunrise":1636582041,"sunset":1636619097},"timezone":32400,"id":1835848,"name":"Seoul","cod":200}
{"coord":{"lon":139.6917,"lat":35.6895},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":292.32,"feels_like":291.28,"temp_min":290.73,"temp_max":293.54,"pressure":1004,"humidity":38},"visibility":10000,"wind":{"speed":0.89,"deg":239,"gust":3.13},"clouds":{"all":20},"dt":1636597012,"sys":{"type":2,"id":268105,"country":"JP","sunrise":1636578769,"sunset":1636616265},"timezone":32400,"id":1850144,"name":"Tokyo","cod":200}
{"coord":{"lon":-74.006,"lat":40.7143},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":284.13,"feels_like":282.33,"temp_min":277.3,"temp_max":287.12,"pressure":1023,"humidity":40},"visibility":10000,"wind":{"speed":0.45,"deg":285,"gust":0.89},"clouds":{"all":1},"dt":1636597072,"sys":{"type":2,"id":2039034,"country":"US","sunrise":1636544237,"sunset":1636580566},"timezone":-18000,"id":5128581,"name":"New York","cod":200}
참고 UrlJoin
from urllib import parse
baseUrl = 'http://www.example.com/html/a.html'
print(parse.urljoin(baseUrl, 'b.html')) >>http://www.example.com/html/b.html
print(parse.urljoin(baseUrl, 'sub/c.html')) >>>http://www.example.com/html/sub/c.html
print(parse.urljoin(baseUrl, '/sub/d.html')) >>>http://www.example.com/sub/d.html
print(parse.urljoin(baseUrl, '../sub/e.html')) >>>http://www.example.com/sub/e.html
print(parse.urljoin(baseUrl, '../temp/f.html')) >>>http://www.example.com/temp/f.html
'python' 카테고리의 다른 글
[웹크롤링] 웹사이트에서 정보수집 (0) | 2021.11.11 |
---|---|
[웹크롤링]BeautifulSoup (0) | 2021.11.11 |
[웹크롤링] 파일 저장 (0) | 2021.11.11 |
[웹크롤링]이미지 다운로드 (0) | 2021.11.11 |
[웹크롤링]requests (0) | 2021.11.11 |