https://api.upbit.com/v1/orderbook?markets=KRW-XRP
위 주소에서 가격을 크롤링 하려면 어떻게 해야할까요?
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="theme-color" content="#000000">
<body bgcolor = "#000000" text="#01DF74">
<font size="5px">
<font face="나눔고딕">
<font weight="bold">
<style>
table {border-collapse: collapse}
td, th {padding:5px; width:120px}
</style>
<script src="https://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
// 전역 변수 세팅
var usd = 0;
var alert_array = new Array();
// 천단위 콤마 함수
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
// 숫자 외 문자열 제거 함수
function numberDeleteChar(x) {
return x.toString().replace(/[^0-9]+/g, '');
}
// 소수점 함수
function deleteThirdDecimals(x) {
var stringX = x.toString();
if (stringX.includes('.')) {
return stringX.substring(0, stringX.indexOf('.') + 2)
} else {
return x.toString();
}
}
// upbit 함수
function upbitxrp(){
$.get('https://api.upbit.com/v1/orderbook?markets=KRW-XRP', function(data) {
var upbit_xrp = parseFloat(data[0].ask_price);
$('#upbit_XRP').html('' + numberWithCommas(upbit_xrp) + ' 원');
});
}
// 현재 시간 갱신
function CurrentTime() {
var d = new Date();
$("#lastUpdate").html(d.toString());
}
// 갱신 함수
function proc() {
try {
upbitxrp(); //
alert_start(); // 알람 확인
CurrentTime(); // 갱신 시간
} catch(e){
} finally {
setTimeout("proc()", 10000); //10초후 재시작
}
}
</script>
</head>
<body onLoad="proc()">
<font size="5px">
<p> 업비트 XRP : <span id="upbit_XRP"></span> </p>
</body>
</html>