이 기능은 hanspell 모듈을 사용하였습니다.
This function was used by the hanspell module.
출처 : https://npmjs.com/package/hanspell
API는 모두 GET 메서드를 사용합니다
https://api.aramy.net/v1/grammar?string={검사할 문장}
// node-fetch
let text = '검사할 문장'
const fetch = require('node-fetch')
fetch(`https://api.aramy.net/v1/grammar?string=${encodeURI(text)}`)
.then(res => res.json())
.then(json => {
console.log(`라이선스 : ${json.license}`)
console.log(`원래 문장 : ${json.original}`)
console.log(`틀린 부분 : ${json.wrong}`)
console.log(`추천 : ${json.suggestions}`)
console.log(`해설 : ${json.more}`)
});
// request
let text = '검사할 문장'
let api_url = `https://api.aramy.net/v1/grammar?string=${encodeURI(text)}`
const request = require('request');
let options = {
url: api_url
}
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
let json = JSON.parse(body)
console.log(`라이선스 : ${json.license}`)
console.log(`원래 문장 : ${json.original}`)
console.log(`틀린 부분 : ${json.wrong || 0}`)
console.log(`추천 : ${json.suggestions || '틀린 부분 없음'}`)
console.log(`해설 : ${json.more || '틀린 부분 없음'}`)
} else {
console.log('error = ' + response.statusCode);
}
});
import requests
response = requests.get("https:/api.aramy.net/v1/grammar?string=검사할문장")
result = response.json()
if response.status_code == 200:
print(result)
else:
print(f"Error Code: {response.status_code}")