<!
DOCTYPE
html>
<
html
lang
=
"zh-CN"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0"
>
<
title
>农历显示</
title
>
<
style
>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
#lunar-info {
font-size: 24px;
color: #333;
}
</
style
>
</
head
>
<
body
>
<
h1
>今日农历信息</
h1
>
<
div
id
=
"lunar-info"
>加载中...</
div
>
<
script
>
// 调用API获取农历数据
fetch('https://api.ahfi.cn/api/nlrq')
.then(response => response.json())
.then(data => {
if (data.code === 200) {
const lunarInfo = data.data.lunar; // 农历信息
const seasonal = data.data.seasonal; // 节气信息
const Thisyear = data.data.Thisyear; // 年份信息
// 拼接显示内容
const infoText = `今天是:${data.data.time}<
br
>农历:${lunarInfo} (${Thisyear})<
br
>节气:${seasonal}`;
document.getElementById('lunar-info').innerHTML = infoText;
} else {
document.getElementById('lunar-info').innerText = '数据加载失败,请稍后再试!';
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('lunar-info').innerText = '网络错误,请检查连接!';
});
</
script
>
</
body
>
</
html
>