秀人网图片随机图片展示网站搭建 资源+源码 适合任何图片站
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

注:本文来自网络,仅供技术分享,可替换原作者提供的图片,用来做任何图片站
演示站1:https://rj.hostloc.ltd
演示站2:http://v2ex.ltd
秀人随机图搭建教程1.首先是图包
https://xiuren.pages.dev/xiuren-url.zip,下载这个zip,然后解压,然后服务器上:
wget -x -i xiuren-url.txtwget -x -i xiuren-url.txtwget -x -i xiuren-url.txt总大小75g的样子,请确认盘大小足够
2.然后是html
https://xiuren.pages.dev/xiuren.zip,这是html下载链接
3.最后是php的api
html需要一个random.php的api,这个api返回的是json格式
我前后试了三种方案,这里全部放出来分享给大家,当然也请有能力大佬看看有没有更好的办法
首先这个php需要返回这样的数据:
{"title":"[XiuRen秀人网]第213期MAGIC写真","imgs":["https://rj.hostloc.ltd/uploadfile/202001/6/7C05727159.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/0705727341.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/A705727374.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/9C05727945.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/2705727174.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/5F05727780.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/CB05727279.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/B505728892.jpg"]}{"title":"[XiuRen秀人网]第213期MAGIC写真","imgs":["https://rj.hostloc.ltd/uploadfile/202001/6/7C05727159.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/0705727341.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/A705727374.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/9C05727945.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/2705727174.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/5F05727780.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/CB05727279.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/B505728892.jpg"]}{"title":"[XiuRen秀人网]第213期MAGIC写真","imgs":["https://rj.hostloc.ltd/uploadfile/202001/6/7C05727159.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/0705727341.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/A705727374.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/9C05727945.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/2705727174.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/5F05727780.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/CB05727279.jpg","https://rj.hostloc.ltd/uploadfile/202001/6/B505728892.jpg"]}第一个方案是,把所有的json按行放在txt里面,然后php随机读取一行,然后返回,代码如下:
<?php header('Content-Type:application/json; charset=utf-8');$f='1.txt'; //文件名$a=file($f); //把文件的所有内容获取到数组里面$n=count($a); //获得总行数$rnd=rand(0,$n); //产生随机行号$rnd_line=$a[$rnd]; //获得随机行echo "$rnd_line"; //显示结果?><?php header('Content-Type:application/json; charset=utf-8');$f='1.txt'; //文件名$a=file($f); //把文件的所有内容获取到数组里面$n=count($a); //获得总行数$rnd=rand(0,$n); //产生随机行号$rnd_line=$a[$rnd]; //获得随机行echo "$rnd_line"; //显示结果?><?php header('Content-Type:application/json; charset=utf-8');$f='1.txt'; //文件名$a=file($f); //把文件的所有内容获取到数组里面$n=count($a); //获得总行数$rnd=rand(0,$n); //产生随机行号$rnd_line=$a[$rnd]; //获得随机行echo "$rnd_line"; //显示结果?>1.txt里面放的就是所有的json,我的文件是这个,https://xiuren.pages.dev/xiurenjson.zip,下载后批量修改下域名就能用
缺点:内存好像有问题,在多人访问时,内存非常容易爆,然后php就没办法返回信息,不知道是代码的问题还是什么,希望有大佬指定
第二个方案是把json放进mysql,然后mysql随机读取
我用的方法是HeidiSQL文件导入,读取的代码是这个:
<?phpheader('Content-Type:application/json; charset=utf-8');$mysqli = new mysqli("localhost", "name", "password", "db");$sql = "select * from u2 order by rand() limit 1";$result = $mysqli->query($sql);$res = mysqli_fetch_array($result);echo $res[0];$mysqli->close();?><?phpheader('Content-Type:application/json; charset=utf-8');$mysqli = new mysqli("localhost", "name", "password", "db");$sql = "select * from u2 order by rand() limit 1";$result = $mysqli->query($sql);$res = mysqli_fetch_array($result);echo $res[0];$mysqli->close();?><?phpheader('Content-Type:application/json; charset=utf-8');$mysqli = new mysqli("localhost", "name", "password", "db");$sql = "select * from u2 order by rand() limit 1";$result = $mysqli->query($sql);$res = mysqli_fetch_array($result);echo $res[0];$mysqli->close();?>这个方案倒是没太大缺点,就是导入可能有点麻烦,php按行导入我不会,会的大佬可以指点一下
第三个方案也是我在用的方案,就是redis,速度非常快
写入的代码:
<?php$file = fopen("1.txt","r"); while(! feof($file)){$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$redis->set(fgets($file), "name");}fclose($file);?><?php$file = fopen("1.txt","r"); while(! feof($file)){$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$redis->set(fgets($file), "name");}fclose($file);?><?php$file = fopen("1.txt","r"); while(! feof($file)){$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$redis->set(fgets($file), "name");}fclose($file);?>读取的代码:
<?phpheader('Content-Type:application/json; charset=utf-8');$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$arList = $redis->RANDOMKEY("*");print_r($arList);?><?phpheader('Content-Type:application/json; charset=utf-8');$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$arList = $redis->RANDOMKEY("*");print_r($arList);?><?phpheader('Content-Type:application/json; charset=utf-8');$redis = new Redis();$redis->connect('xxxxxx.com', 6666);$redis->auth('password');$arList = $redis->RANDOMKEY("*");print_r($arList);?>要搭建的话,第一步下好图片后,把对应的文件夹放到web目录下,然后批量修改我那个json里面的域名就行
[免费VPS]历史优惠活动内容
猜你可能想看的VPS
- HostYun 老品牌升级,圣何塞双程 GIA VPS 限时九折,100全球[VPS测评]
- HostDoc→£5 年 512MB 内存 10GB 空间 1TB 流量虚拟空间(主机)
- 优惠 ZJI 美国山河城三网直连独立服务器八折优惠 32G 内存月付 9独立服务器[U]
- StockServers→$5 月 1 核独享 4GB 内存 100GB虚拟空间(主机)
- 真实测评 野草云→1 核 1G 20G 硬盘 200G 流量 30Mbp香港VPS[主机]
- TmhHost 黄金周活动,充值返 10%,日本软银 韩国 CN2 洛杉日本VPS[主机]
- [11.11]ZJI→香港服务器 65 折 日本站群服务器 7 折 充 站群服务器[IP]
- CloudCone→$2.49 月 768MB 内存 10GB SAS 虚拟空间(主机)
- thinkphp5 中文乱码解决方案全球[VPS测评]
- NecoVM 五一促销,国内联通 移动大带宽 NAT 最低 24 元 月全球[VPS测评]
- Zcloudme→$59.5 月 2*E5-2620v3 32G 内存 香港VPS[主机]
- Worria→$60 月-E3 1230v2 8GB 1TB 2IP 1日本VPS[主机]
- RAKsmart→无限流量服务器月付 46 美元起 VPS 全场 8 折全球[VPS测评]
- 虎字下面的几变成一个口中间有个羊字是什么成语?全球[VPS测评]
- 优质低价 racknerd→“白色情人节”便宜 VPS 限量 100 个全球[VPS测评]
- Mtbone → 泰国VPS 300THB 月 1核1G20G硬盘 无限全球[VPS测评]
- 云服务器能干什么?有几十种玩法?阿里云,腾讯云服务器如何购买?全球[VPS测评]
- 2022年黄河流域跨境电商博览会将于8月26日至28日在青岛西海岸新区举全球[VPS测评]
- 2022年有哪些顶级托管服务提供商全球[VPS测评]
- 又有美议员窜访台,中国驻美大使馆:“中方将对美国的挑衅采取果断的反制措施美国VPS[主机]
- edgenat,低价年付促销活动,香港vps 4核8G仅300元/年,美美国VPS[主机]
- VPSPlayer,超便宜香港cn2线路小带宽VPS,2核4G内存仅30香港VPS[主机]
- 亿速云双12年终回馈:云服务器2折活动,订单满100元减50元全球[VPS测评]
- 群英云怎么样?2核2G3M华北BGP云服务器,98元/首月;香港cn2v香港VPS[主机]
- 恒星云:喜迎新春香港CN2云服务器,首月9.9元;深圳2核4G云服务器仅香港VPS[主机]
- tmhhost:香港安畅机房三网CN2 GIA VPS,月付45起;美国美国VPS[主机]
- 互盟云元旦活动:云服务器1核2G首月仅18元,香港虚拟主机年付仅1折香港VPS[主机]
- 轻云互联,香港美国vps终身8.8折17元/月起,cn2直连线路,50G美国VPS[主机]
- UCloud云服务器2020年度大促:北京/上海云服务器/香港免备案云服香港VPS[主机]
- 港网科技怎么样?国内BGP云主机,2核2G5M带宽仅377.46元/年全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-164610.html











