python - 如何使用请求或其他库从该网页获取 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))
解决方案
推荐阅读
- django - WebSocket握手期间的Django-channels错误:意外的响应代码:404
- python - 试图理解面向对象的编程。如何使用对象组合?
- angular - RxJS distinct 运算符没有从对象数组中获取不同的值
- reactjs - 动态需要图像在 reactjs/nextjs 中不起作用
- swift - 为什么我的 UILabel 无法显示成功获取的值?
- java - 可以将两个参数传递给模态
- matplotlib - 在 Spyder 上安装 Tex
- python - TensorFlow,在 CNN 的混乱中重塑
- javascript - Recharts:响应式 LineChart 网格和线条无法正确呈现,出现在图表之外
- java - namedParameterJdbcTemplate 中的空指针