Fox news API를 다루고 있으며 응답이 저 또는 Python에 대해 알려진 데이터 유형으로 인식되지 않습니다. 다음은 응답 샘플입니다.
// API callback
__jp0({
"kind": "customsearch#search",
"url": {
},
"queries": {
"request": [
{
"totalResults": "791000",
"count": 10,
"startIndex": 1,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"siteSearch": "foxnews.com",
"siteSearchFilter": "i"
}
],
"nextPage": [
{
"totalResults": "791000",
"count": 10,
"startIndex": 11,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"siteSearchFilter": "i"
}
]})
여기에 전체 응답 볼 수있는 API 링크입니다 링크 내가 JSON 또는 알려진 데이터 형식으로 응답을 구문 분석 할은.
API에서 볼 수있는 것은 JSONP 형식 입니다.
표준 형식이므로 응답에서 괄호를 제거한 다음 일반 json과 같이 괄호 안에있는 내용을로드 할 수 있습니다.
data_json = response_json.split("(", 1)[1].strip(")")
parsed_json = json.loads(data_json)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다