自制「单向历」网页版
source link: https://immmmm.com/dan-xiang-li-page/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
自制「单向历」网页版
在线体验:https://edui123.com/rili/
Github 上找到一个 PHP 版的 calendar_api,调用非常方便。可为了一个 API 开个 PHP 也是够过分,其实也就为了解决两个问题:
- 自动更新日期
- 绕过 Referer 验证
顺利访问以下图片地址:
https://img.owspace.com/Public/uploads/Download/2022/0109.jpg
寻思,直接 JavaScript 不香吗?
完整代码直接右键查看页面源码即可,说明两点:更新日期 js 大法,Referer 头部加一句搞定。
window.onload=function(){getDate()}
function getDate(){
var d=new Date(),y=d.getFullYear(),m=d.getMonth()+1,n=d.getDate();
m=m>9?m:"0"+m;n=n>9?n:"0"+n;
var img= "<img src='https://img.owspace.com/Public/uploads/Download/"+y+"/"+m+n+".jpg'>"
document.getElementById("rili").innerHTML=img
}
<meta name="referrer" content="same-origin">
当然,API 的好处是方便调用,不用又是加 html 又是加 js 的,直接图片 src 调用地址即可:
<img src="https://www.aigeek.top/api/rili.php">
<img src="https://immmmm.com/api/rili.php">
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK