복붙노트

[HADOOP] 파이썬에서 다중 응답 분석

HADOOP

파이썬에서 다중 응답 분석

나는 하둡 (webhdfs)에 액세스 할 수 curl 명령을 사용하고 및 HTTP 응답 구문 분석을위한 파이썬을 사용하고 있습니다.

그러나 컬 명령을 소성 후, 복수 응답이 반환되고있다.

curl -i  "http://host:50070/webhdfs/v1/user/hduser/pigtest?op=GETFILESTATUS"

HTTP/1.1 401 Authentication required
Cache-Control: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Content-Type: plain/text
Transfer-Encoding: chunked
Server: Jetty(6.1.26.hwx)

HTTP/1.1 200 OK
Cache-Control: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26.hwx)

{"FileStatus":{"accessTime":1452062206193,"blockSize":134217728,"childrenNum":0,"fileId":39295,"group":"hdfs","length":753,"modificationTime":1452062206392,"owner":"hduser","pathSuffix":"","permission":"644","replication":2,"storagePolicy":0,"type":"FILE"}} 

파이썬에서 어떻게 이러한 복수 응답을 구문 분석합니까?

감사

해결법

    from https://stackoverflow.com/questions/34786880/multiple-response-parsing-in-python by cc-by-sa and MIT license