[R] HTTP Client - httr

R 2015. 8. 3. 20:21



R에는 httr 이라는 HTTP Client api가 존재한다. keep-alive를 지원하며, 때에 따라 성능이 빠르다.


예제 1)- get

library(httr) 

r <- GET("http://www.naver.com")

r$status_code

r$cookies

r$request



예제 2)- post


#install(httr)

library(httr) 


user <- "samuel"

password <- "sam8a2" 

POST(url = 'http://localhost/login',      

config = c(authenticate(user, password, "basic"), 

add_headers(Connection = "keep-alive"),

accept_json()),      

body = "{'auth-key:'sadfasdf1231'}"

)



'R' 카테고리의 다른 글

[R] 리눅스 (Red-hat 계열) 모듈 설치  (0) 2015.08.05
[R] null/na 체크 (is null)  (0) 2015.08.04
R에서 한줄 읽기 (readline)  (0) 2015.08.01
R에서 파일 쓰기 (write)  (0) 2015.08.01
R 리스트 인덱스  (0) 2015.07.31
Posted by '김용환'
,