當你點擊一個提示,一個XHR請求使用zone_id發送到https://api.socar.kr/reserve/zone_info,你可能不得不通過使用頁面內容過濾掉你想要的區域,我現在沒有更多的時間花在這個上面了,但是這個重新創建了請求:
import requests
from time import time, sleep
# These params will be for https://api.socar.kr/reserve/oneway_zone_list
# which we can get the zone_ids from.
params = {"type": "start", "_": str(time())}
# We use the zone_id from each dict we parse from the json receievd
params2 = {"zone_id": ""}
with requests.Session() as s:
s.get("http://www.socar.kr/reserve#jeju")
s.headers.update({
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64)"})
r = s.get("https://api.socar.kr/reserve/oneway_zone_list", params=params)
result = r.json()["result"]
for d in result:
params2["zone_id"] = d["zone_id"]
params2["_"] = str(time())
sleep(1)
r2 = s.get("https://api.socar.kr/reserve/zone_info", params=params2)
print(r2.json())
在結果中的每個d是一個字典,如:
{u'zone_lat': u'37.248859', u'zone_id': u'2902', u'zone_region1_short': u'\uacbd\uae30', u'zone_open_time': u'00:00:00', u'zone_region1': u'\uacbd\uae30\ub3c4', u'zone_close_time': u'23:59:59', u'zone_name': u'SK\ud558\uc774\ub2c9\uc2a4 \uc774\ucc9c', u'open_weekend': u'close', u'zone_region3': u'\ubd80\ubc1c\uc74d', u'zone_region2': u'\uc774\ucc9c\uc2dc', u'zone_lng': u'127.490639', u'zone_addr': u'\uacbd\uae30\ub3c4 \uc774\ucc9c\uc2dc \ubd80\ubc1c\uc74d \uc544\ubbf8\ub9ac 707'}
那裏,可能其它的信息,將允許您按特定的地方進行過濾,我不懂韓語,所以我不能完全跟着怎麼樣數據相關。
第二請求給我們像一個字典:
{u'retCode': u'1', u'retMsg': u'', u'result': {u'oper_way': u'\uc655\ubcf5', u'notice': u'<br>\u203b \ubc18\ub4dc\uc2dc \ubc29\ubb38\uc790 \uc8fc\ucc28\uc7a5 \uc9c0\uc815\uc8fc\ucc28\uad6c\uc5ed\uc5d0 \ubc18\ub0a9\ud574\uc8fc\uc138\uc694.<br>', u'notice_oneway': u'', u'zone_addr': u'\uacbd\uae30\ub3c4 \uc774\ucc9c\uc2dc \ubd80\ubc1c\uc74d \uc544\ubbf8\ub9ac 707', u'total_num': 2, u'able_num': 2, u'visit': u'\uc131\uc6b02\ub2e8\uc9c0 \uc544\ud30c\ud2b8 \uae30\uc900 \uc804\ubc29 \ud604\ub300\uc5d8\ub9ac\ubca0\uc774\ud130 \ubc29\uba74\uc73c\ub85c \ud6a1\ub2e8\ubcf4\ub3c4 \uc774\uc6a9 \ud6c4 \ud558\uc774\ub2c9\uc2a4 \uc774\ucc9c \ubc29\ubb38\uc790 \uc8fc\ucc28\uc7a5 \ub0b4 \uc3d8\uce74\uc804\uc6a9\uc8fc\ucc28\uad6c\uc5ed', u'zone_alias': u'\ud558\uc774\ub2c9\uc2a4 \ubc29\ubb38\uc790 \uc8fc\ucc28\uc7a5', u'zone_attr': u'[\uc774\ubca4\ud2b8]', u'state': True, u'link': u'http://blog.socar.kr/4074', u'oper_time': u'00:00~23:59', u'lat': u'37.248859', u'zone_name': u'SK\ud558\uc774\ub2c9\uc2a4 \uc774\ucc9c', u'lng': u'127.490639', u'zone_props': 0, u'visit_link': u'http://dmaps.kr/24ij6', u'zone_id': u'2902'}}
同樣不知道的一切就是在那裏,但你可以在u'notice和許多其他信息請參見HTML標籤。
非常感謝您對我的貢獻。這太棒了。 – DSDS