我亏一点 - 1585364631
type: channel
link: https://blog.997818.xyz/index.php/author/1
description: 1585364631
items: 油猴 1688列表自动爬取数据
items: 苹果cms10 列表和搜索过滤会员组没有权限的数据
items: PHP多级分类数据列表转为树型父子结构
items: Javascript 实现阿拉伯数字转中文数字
items: Centos7系统的笔记本，启动摄像头
items: mysql5.7 sql语句实现父子查询
items: Kubernetes使用kubeeasy部署集群
items: Kubernetes Pod的操作指令
items: CentOS7 搭建http的yum源
items: Kubernetes集群ezdown脚本一键部署

油猴 1688列表自动爬取数据
type: item
date: 2026-03-14T02:41:00+00:00
description: 油猴 1688列表自动爬取数据此代码为油猴脚本，用于1688商品搜索列表和店铺商品列表爬取自动数据，请在商品两处地方补充自己的代码，将商品信息上传到自己的数据库。代码原理是，hook 1688的xhr请求，请求中途拦截响应，取出请求内容处理。但是有些请求是通过JSONP的方式，就是通过script标签动态插入body，从而让浏览器加载，所以同样监听了script加载内容回调，符合的响应内容则返回。对于商品详情的数据，则通过iframe，父页面开启监听，子页面进行推送。// ==UserScript== // @name 1688列表自动爬取数据 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 1688列表自动爬取数据 // @author 我亏一点 // @match *.1688.com/page/offerlist.htm* // @match *.1688.com/offer/*.html* // @match *.1688.com/selloffer/offer_search.htm* // @icon https://s1.ax1x.com/2022/10/14/xwsJYT.png // @grant none // ==/UserScript== (function () { "use strict"; const config = { lock: false, //是否自动爬取 true为是，false为否 run_status: false, //是否正在拦截爬取 sleep: 5, // 爬取间隔 (秒) iframe_timeout: 3600, // 最大等待时间（秒），防止卡死 debug: false, // 是否开启测试，开启只会爬一个数据 data: [], //数据集 is_iframe: window.self !== window.top, type: "", // 页面类型 shop_list为店铺商品列表，goods_list为搜索商品列表，detail为商品详情 type_match: { shop_list: "mtop.alibaba.alisite.cbu.server.moduleasyncservice", // 店铺商品列表 goods_list: "mtop.relationrecommend.wirelessrecommend.recommend", // 搜索商品列表 }, }; //================创建面板开始==================== // 创建一个 div 元素用于显示日志 const logDiv = document.createElement("div"); logDiv.id = "log-div-1688"; logDiv.style.position = "fixed"; logDiv.style.bottom = "10px"; logDiv.style.left = "10px"; logDiv.style.width = "400px"; logDiv.style.height = "300px"; logDiv.style.overflowY = "auto"; logDiv.style.border = "10px solid black"; logDiv.style.backgroundColor = "white"; logDiv.style.zIndex = 9999; logDiv.style.padding = "20px"; logDiv.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.1)"; logDiv.style.wordWrap = "break-word"; logDiv.style.overflowWrap = "break-word"; logDiv.style.fontFamily = "monospace"; logDiv.style.fontSize = "12px"; // 日志容器 - 使用单独的容器存放日志条目 const logContainer = document.createElement("div"); logContainer.id = "log-container-1688"; logContainer.style.maxHeight = "240px"; logContainer.style.overflowY = "auto"; logDiv.appendChild(logContainer); // 日志头部 con…

苹果cms10 列表和搜索过滤会员组没有权限的数据
type: item
date: 2026-03-13T14:21:00+00:00
description: 苹果cms10 列表和搜索过滤会员组没有权限的数据苹果cms10的列表中，会出现会员组没有权限的数据，只有点进去才会提示登录。1.新版本后台-》网站基础参数-》性能优化-》数据权限过滤开启即可2.老版本编辑文件application/common/model/Vod.php找到listData方法，增加过滤方法public function listData($where,$order,$page=1,$limit=20,$start=0,$field='*',$addition=1,$totalshow=1) { $page = $page > 0 ? (int)$page : 1; $limit = $limit ? (int)$limit : 20; $start = $start ? (int)$start : 0; if(!is_array($where)){ $where = json_decode($where,true); } $where2=''; if(!empty($where['_string'])){ $where2 = $where['_string']; unset($where['_string']); } // =====修改开始===== // 增加会员组过滤方法 $where3 = []; // 如果是用户请求 if(isset($GLOBALS['user'])){ $category_ids = array_filter(explode(',',$GLOBALS['user']['group']['group_type'])); $where3['type_id'] = ['in',$category_ids]; } $limit_str = ($limit * ($page-1) + $start) .",".$limit; if($totalshow==1) { // 增加where3查询 $total = $this->where($where)->where($where2)->where($where3)->count(); } // 增加where3查询 $list = Db::name('Vod')->field($field)->where($where)->where($where2)->where($where3)->order($order)->limit($limit_str)->select(); // =====修改结束===== //分类 $type_list = model('Type')->getCache('type_list'); //用户组 $group_list = model('Group')->getCache('group_list'); foreach($list as $k=>$v){ if($addition==1){ if(!empty($v['type_id'])) { $list[$k]['type'] = $type_list[$v['type_id']]; $list[$k]['type_1'] = $type_list[$list[$k]['type']['type_pid']]; } if(!empty($v['group_id'])) { $list[$k]['group'] = $group_list[$v['group_id']]; } } } return ['code'=>1,'msg'=>lang('data_list'),'page'=>$page,'pagecount'=>ceil($total/$limit),'limit'=>$limit,'total'=>$total,'list'=>$list]; }

PHP多级分类数据列表转为树型父子结构
type: item
date: 2024-01-10T01:36:00+00:00
description: PHP多级分类数据列表转为树型父子结构function formatToTree($array, $pid = 0, $pidName = 'parent_id') { return array_values(array_map(function ($item) use ($array, $pid) { $item['children'] = formatToTree($array, $item['id']); return $item; },array_filter($array,function ($item) use ($pidName,$pid) { return $item[$pidName] === $pid; }))); }$array为mysql查询出来的列表数据$pid为最上级父节点id$pidName为父id字段

Javascript 实现阿拉伯数字转中文数字
type: item
date: 2023-11-13T06:55:00+00:00
description: 代码（仅适用亿位以下）：function numToChinese(num) { const CN_NUM = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; const CN_UNIT = ['', '十', '百', '千', '万', '十', '百', '千', '亿']; let numStr = String(num); let len = numStr.length; let result = ''; if (len === 0) { return '零'; } for (let i = 0; i < len; i++) { let n = numStr.charAt(i); let unitIndex = len - i - 1; let numIndex = parseInt(n); let preUnit = CN_UNIT[unitIndex]; let preNum = CN_NUM[numIndex]; let replaceNum = preNum ? preNum : ''; if (unitIndex > 0 && numIndex === 0) { replaceNum = ''; } else if (numIndex > 0) { replaceNum = preNum; } result += replaceNum + preUnit; } result = result.replace(/零(千|百|十|)/g, '零$1'); let matchs = (result.match(/([亿|万|千|百|十]{2,})/g))||[] for (const iterator of matchs) { result = result.replace(iterator,iterator.slice(0,1) + "零") } result = result.replace("一十","十") return result.endsWith("零") ? result.slice(0,-1) : result; } console.log(numToChinese(12));结果：十二

Centos7系统的笔记本，启动摄像头
type: item
date: 2023-07-18T06:21:56+00:00
description: Centos7系统的笔记本，启动摄像头1. 确认摄像头已正确安装。在终端中运行以下命令，检查摄像头是否被正确识别：dmesg | grep -i webcam如果摄像头被正确识别，你应该能在输出中看到相关的信息。2. 检查摄像头是否已经启动。在终端中运行以下命令，启动摄像头：modprobe -r uvcvideo modprobe uvcvideo

mysql5.7 sql语句实现父子查询
type: item
date: 2023-05-02T06:25:45+00:00
description: mysql5.7 sql语句实现父子查询1.数据表创建SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS `goods_metas`; CREATE TABLE `goods_metas` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名', `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型', `count` int(11) NULL DEFAULT 0 COMMENT '统计', `parent` int(11) NULL DEFAULT 0 COMMENT '父编号（只有class需要）', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `name`(`name`, `type`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; INSERT INTO `goods_metas` VALUES (1, '美甲', 'class', 0, 0); INSERT INTO `goods_metas` VALUES (2, '长甲', 'class', 0, 1); INSERT INTO `goods_metas` VALUES (3, '短甲', 'class', 0, 1); INSERT INTO `goods_metas` VALUES (4, '可爱', 'tag', 0, 0); INSERT INTO `goods_metas` VALUES (5, '简约', 'tag', 0, 0); INSERT INTO `goods_metas` VALUES (6, '测试', 'class', 0, 2); SET FOREIGN_KEY_CHECKS = 1;2.根据父id查所有子节点将{id}修改为查询的父id不包含父节点自身select * from goods_metas where id in (SELECT id FROM (SELECT * FROM goods_metas where type="class") goods_metas, (SELECT @pid := '{id}') pd WHERE FIND_IN_SET(parent, @pid) > 0 AND @pid := concat(@pid, ',', id));id=0查询结果+----+----------+-------+-------+--------+ | id | name | type | count | parent | +----+----------+-------+-------+--------+ | 2 | 长甲 | class | 0 | 1 | | 3 | 短甲 | class | 0 | 1 | | 6 | 测试 | class | 0 | 2 | +----+----------+-------+-------+--------+

Kubernetes使用kubeeasy部署集群
type: item
date: 2023-03-23T14:32:41+00:00
description: Kubernetes使用kubeeasy部署集群1.环境准备主机信息（一定要双网卡）主机名NAT网卡本地网卡节点状态master10.107.24.80192.168.50.80masternode10.107.24.81192.168.50.81worker准备文件chinaskills_cloud_paas_v2.0.2.iso[root@master ~]# mount -o loop /dev/cdrom /mnt/ [root@master ~]# cp -rf /mnt/* /opt/ [root@master ~]# umount /mnt/ [root@master ~]# ls /opt/ centos extended-images helm-v3.7.1-linux-amd64.tar.gz kubeeasy kubevirt.tar.gz dependencies harbor-offline.tar.gz istio.tar.gz kubernetes.tar.gz2.离线安装步骤2.1 安装kubeeasy[root@master ~]# cp -rf /opt/kubeeasy /usr/bin/ [root@master ~]# chmod +x /usr/bin/kubeeasy2.2 安装集群依赖包[root@master ~]# kubeeasy install dependencies \ --host 10.107.24.80,10.107.24.81 \ --user root \ --password 000000 \ --offline-file /opt/dependencies/base-rpms.tar.gz[2023-03-20 01:20:52] INFO: [start] bash kubeeasy install dependencies --host 10.107.24.80,10.107.24.81 --user root --password ****** --offline-file /opt/dependencies/base-rpms.tar.gz [2023-03-20 01:20:52] INFO: [offline] unzip offline dependencies package on local. [2023-03-20 01:20:54] INFO: [offline] unzip offline dependencies package succeeded. [2023-03-20 01:20:54] INFO: [install] install dependencies packages on local. [2023-03-20 01:22:36] INFO: [install] install dependencies packages succeeded. [2023-03-20 01:22:37] INFO: [offline] 10.107.24.80: load offline dependencies file [2023-03-20 01:22:39] INFO: [offline] load offline dependencies file to 10.107.24.80 succeeded. [2023-03-20 01:22:39] INFO: [install] 10.107.24.80: install dependencies packages [2023-03-20 01:22:40] INFO: [install] 10.107.24.80: install dependencies packages succeeded. [2023-03-20 01:22:41] INFO: [offline] 10.107.24.81: load offline dependencies file [2023-03-20 01:22:46] INFO: [offline] load offline dependencies file to 10.107.24.81 succeeded. [2023-03-20 01:22:46] INFO: [install] 10.107.24.81: install dependencies packages [2023-03-20 01:24:26] INFO: [install] 10.107.24.81: install dependencies packages succeeded. See detailed log >> /var/log/kubeinstall.…

Kubernetes Pod的操作指令
type: item
date: 2023-03-23T08:36:51+00:00
description: Kubernetes Pod的操作指令查看默认命名空间的pod 默认命名空间： defaultkubectl get pod | pods | poNAME READY STATUS RESTARTS AGE exam 1/1 Running 0 2d1h查看指定命名空间的podkubectl get pod -n kube-systemNAME READY STATUS RESTARTS AGE coredns-78fcd69978-49kgg 1/1 Running 0 2d1h coredns-78fcd69978-hq69g 1/1 Running 0 2d1h ......查看所有命名空间podkubectl get pod -ANAMESPACE NAME READY STATUS RESTARTS AGE dashboard-en dashboard-en-55596d469-lrnp9 1/1 Running 0 2d1h default exam 1/1 Running 0 2d1h istio-system grafana-6ccd56f4b6-7sfwt 1/1 Running 0 2d1h ......查看pod详细信息kubectl get pod -o wideNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES exam 1/1 Running 0 2d1h 10.244.1.5 k8s-worker-node1 <none> <none>实时监控pod详细kubectl get pod -wNAME READY STATUS RESTARTS AGE exam 1/1 Running 0 2d1h ^C命令行直接创建podkubectl run mariadb --image=hyperf-mariadb:v1.0模板创建podapiVersion: v1 kind: Pod metadata: name: mariadb spec: containers: - name: mariadb image: hyperf-mariadb:v1.0 ports: - containerPort: 3307create 仅仅是在不存在时创建，如果已经存在则会报错，apply在不存在时创建，在存在时更新配置kubectl create -f k8s.yml kubectl apply -f k8s.yml 删除podkubectl delete mariadbkubectl delete -f k8s.yml进入Pod中的容器# 默认进入pod中第一个容器 kubectl exec -it Pod名称 -- 命令 # 进入Pod中指定容器 kubectl exec -it Pod名称 -c 容器名称 -- 命令查看pod日志# 默认查看pod中所有容器日志 kubectl logs -f(可选，实时) pod名称 # 查看pod中单个容器日志 kubectl logs -f pod名称 -c 容器名称查看pod描述信息kubectl describe pod pod名称

CentOS7 搭建http的yum源
type: item
date: 2023-03-20T05:01:26+00:00
description: CentOS7 搭建http的yum源1. 环境准备永久关闭防火墙[root@yum ~]# systemctl stop firewalld && systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.永久关闭selinux[root@yum ~]# setenforce 0 [root@yum ~]# sed -i 's/enforcing/disabled/g' /etc/selinux/config [root@yum ~]# cat /etc/selinux/config | grep = # SELINUX= can take one of these three values: SELINUX=disabled # SELINUXTYPE= can take one of three values: SELINUXTYPE=targeted 挂载系统镜像源[root@yum ~]# mount -o loop /dev/cdrom /mnt/ [root@yum ~]# mkdir /opt/centos [root@yum ~]# cp -rf /mnt/* /opt/centos/ [root@yum ~]# umount /mnt/备份原有yum源[root@yum ~]# mkdir yumbackup [root@yum ~]# mv /etc/yum.repos.d/* yumbackup/配置centos系统镜像源[root@yum ~]# cat << EOF > /etc/yum.repos.d/yum.repo > [centos] > name=centos > baseurl=file:///opt/centos > gpgcheck=0 > enable=1 > EOF [root@yum ~]# cat /etc/yum.repos.d/yum.repo [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enable=1 [root@yum ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: centos [root@yum ~]# yum repolist Loaded plugins: fastestmirror Determining fastest mirrors centos | 3.6 kB 00:00:00 (1/2): centos/group_gz | 153 kB 00:00:00 (2/2): centos/primary_db | 3.3 MB 00:00:00 repo id repo name status centos centos 4,070 repolist: 4,070安装工具yum install -y vim net-tools2.配置http源安装httpyum install -y httpd systemctl restart httpd systemctl enable httpd创建软连接指向源路径[root@yum html]# ln -s /opt/* /var/www/html/删除httpd默认页内容echo "" > /etc/httpd/conf.d/welcome.conf重启httpd服务systemctl restart httpd

Kubernetes集群ezdown脚本一键部署
type: item
date: 2023-03-19T06:39:16+00:00
description: Kubernetes集群ezdown脚本一键部署1.环境准备主机信息主机名IP地址集群服务node110.107.24.81nodeetcd、api-server、controlor-manager、schedulernode210.107.24.82nodekubelet、kube-proxy、dockermaster10.107.24.83masterkubelet、kube-proxy、docker配置hosts解析10.107.24.81 node1 10.107.24.82 node2 10.107.24.83 master生成SSH身份文件ssh-keygen 一路回车配置免密登入ssh-copy-id -i node1 ssh-copy-id -i node2 ssh-copy-id -i master测试免密登入ssh master ssh node1 ssh node2禁用交换分区swapoff -a sed -i.bak '/swap/s/^/#/' /etc/fstab关闭防火墙systemctl stop firewalld && systemctl disable firewalld安装git和wgetyum install -y git wget2.脚本安装Kubernetes下载ezdown[root@master ~]# wget https://github.com/easzlab/kubeasz/releases/download/3.5.2/ezdown [root@master ~]# chmod +x ezdown下载所需文件# 国内 [root@master ~]# ./ezdown -D # 国外 [root@master ~]# ./ezdown -D -m standard2023-03-19 14:19:49 INFO Action successed: download_all创建集群配置[root@master ~]# ./ezdown -S2023-03-19 14:20:13 INFO Action begin: start_kubeasz_docker 2023-03-19 14:20:13 INFO try to run kubeasz in a container 2023-03-19 14:20:13 DEBUG get host IP: 10.107.24.83 fc0377122adc8726397e25b6f0285e04072e6b76b9f6b9bd1a0dca3b17d6e1a2 2023-03-19 14:20:14 INFO Action successed: start_kubeasz_docker创建新的集群[root@master ~]# docker exec -it kubeasz ezctl new k8s2023-03-19 06:21:22 DEBUG generate custom cluster files in /etc/kubeasz/clusters/k8s 2023-03-19 06:21:22 DEBUG set versions 2023-03-19 06:21:22 DEBUG cluster k8s: files successfully created. 2023-03-19 06:21:22 INFO next steps 1: to config '/etc/kubeasz/clusters/k8s/hosts' 2023-03-19 06:21:22 INFO next steps 2: to config '/etc/kubeasz/clusters/k8s/config.yml'修改新的集群配置文件[root@master ~]# vim /etc/kubeasz/clusters/k8s/hosts# 'etcd' cluster should have odd member(s) (1,3,5,...) [etcd] 10.107.24.83 # master node(s), set unique 'k8s_nodename' for each node # CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.', # and must start and end with an alphanumeric character [kube_master] 10.107.24.83 k8s_nodename='master' # work node(s), set unique …