2012-12-08 4 views

답변

1

그것은 기본적인 XML 데이터를합니다. XML 구문 분석기로 파싱 할 수 있습니다. 나는이 내장 된 XML 파서를 사용하는 방법을 내 머리 위로 떨어져 기억하지 않는다, 그래서 여기 BeautifulSoup로 그것을 할 방법은 다음과 같습니다

import requests 
from BeautifulSoup import BeautifulStoneSoup 

data = requests.get('http://tinychat.com/api/find.room/randomroom').text 
soup = BeautifulStoneSoup(data) 

response = dict(soup.find('response').attrs) 
geoip = dict(soup.find('geoip').attrs) 

이제 responsegeoip 쉽게하는 당신이 할 수있는, 파이썬 사전을 포함 다음 번호와 함께 사용하십시오 :

{ 
    u'rt': u'5.47', 
    u'roomtype': u'show', 
    u'name': u'tinychat^randomroom', 
    u'referer': u'', 
    u'rtmp': u'rtmp://209.212.144.86:443/tinyconf', 
    u'time': u'1354934566', 
    u'result': u'RES' 
}