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

时间:2019-05-22 07:49:43

标签: python django python-3.x

如何使用请求或其他库从此网页获取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))

0 个答案:

没有答案