首页 > 解决方案 > 如何使用请求或其他库从该网页获取 json?

问题描述

如何使用请求或其他库从该网页获取 json?

代码:

request_url = 'http://tour.tmon.co.kr/api/direct/v1/airtktintlapi/api/search/dataList'

headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
    'Connection': 'keep-alive',
    'Content-Length': '1011',
    'Content-Type': 'application/json;charset=UTF-8',
    'Host': 'tour.tmon.co.kr',
    'Origin': 'http://tour.tmon.co.kr',
    'User-Agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
                   +'(KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36')
}

jsonObj = requests.get(request_url, headers=headers).json()

错误:

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

标签: pythondjangopython-3.x

解决方案


推荐阅读