#安装docker#!/bin/sh#关闭SeLinuxsed -i 's/enforcing/disabled/g' /etc/sysconfig/selinuxsetenforce 0#关闭防火墙systemctl stop firewalldsystemctl disable firewalld#安装docker1,curl -fsSL https://get.docker.com/ | sh2,yum install -y yum-utilsyum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repoyum install docker-ce docker-ce-cli containerd.io#添加阿里DNStouch /etc/docker/daemon.jsonvi /etc/docker/daemon.json{"dns": ["223.5.5.5","223.6.6.6"]}#开启docker服务并开启开机自启动systemctl start dockersystemctl enable dockercentos8 TencentOShttps://blog.csdn.net/qq_31803267/article/details/122960656#创建名为mynet的网络docker network create mynet#安装docker-compose#(直接下载安装)curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-composeln -s /usr/local/bin/docker-compose /usr/bin/docker-compose#(pip安装)1、安装python-pipyum -y inst
#!/bin/sh#关闭SeLinuxsed -i 's/enforcing/disabled/g' /etc/sysconfig/selinuxsetenforce 0#关闭防火墙systemctl stop firewalldsystemctl disable firewalld#安装gcc gcc-c++等基础组件tar zxvf package.tar.gzcd packagerpm -Uvh *.rpm --nodeps --forcecd ../#安装apache#安装aprtar zxvf apr-1.7.0.tar.gzcd apr-1.7.0./configure --prefix=/usr/local/aprmake && make installcd ../#安装apr-utiltar zxvf apr-util-1.6.1.tar.gzcd apr-util-1.6.1./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make installcd ../#安装pcretar zxvf pcre-8.00.tar.gzcd pcre-8.00./configure --prefix=/usr/local/pcremake && make installcd ../#安装httpdtar zxvf httpd-2.4.48.tar.gzcd httpd-2.4.48./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr -with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcremake && make installcd ../#设置开机自启动cp -r /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpdsed -i '1 i\#description:Start and stop the Apache HTTP Server' /etc
python主程序和两个静态页面,实现ansible批量执行更新脚本
app.py
import osimport loggingfrom flask import Flask, request, render_template, redirect, url_for, session, render_template_stringimport hashlibimport subprocessimport datetimefrom flask_sqlalchemy import SQLAlchemyapp = Flask(__name__)app.config['SECRET_KEY'] = '自定义32位字符串'app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:passwd@10.0.0.1/python_db'app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = Falsedb = SQLAlchemy(app)class User(db.Model):__tablename__ = 'users' # 指定表名为 'users'id = db.Column(db.Integer, primary_key=True)username = db.Column(db.String(100), unique=True, nullable=False)password = db.Column(db.String(255), nullable=False)class LoginLog(db.Model):__tablename__ = 'login_logs' # 指定表名为 'login_logs'id = db.Column(db.Integer, primary_key=True)username = db.Column(db.String(100), nullable=False)login_time = db.Column(db.DateTime, nullabl
import requestsfrom fake_useragent import UserAgentimport csvfrom datetime import datetimedef convert_created_at(created_at):dt = datetime.strptime(created_at, '%a %b %d %H:%M:%S +0800 %Y')formatted_created_at = dt.strftime('%Y-%m-%d %H:%M:%S')return formatted_created_atdef get_weibo_mid(weibo_id):url = f'https://weibo.com/ajax/statuses/show?id={weibo_id}'header = {'user-agent': UserAgent().random}response = requests.get(url=url, headers=header)if response.status_code == 200:try:json_data = response.json()weibo_mid = json_data.get('mid')if weibo_mid:return weibo_midelse:print("未找到微博 MID。")except Exception as e:print(f"解析微博 MID 时发生异常:{e}")else:print(f"无法获取微博 MID。状态码:{response.status_code}")return Nonedef get_weibo_comments(weibo_id, csv_filename):header = {
import openpyxlimport osfrom copy import copydef get_cell(sheet, cell):# 如果是合并单元格,找到合并区域的起始单元格for merged_cell_range in sheet.merged_cells.ranges:if cell.coordinate in merged_cell_range:return sheet[merged_cell_range.coord.split(':')[0]]return celldef copy_cell_format(src_cell, dest_cell):if src_cell.has_style:dest_cell.font = copy(src_cell.font)dest_cell.border = copy(src_cell.border)dest_cell.fill = copy(src_cell.fill)dest_cell.number_format = src_cell.number_formatdest_cell.protection = copy(src_cell.protection)dest_cell.alignment = copy(src_cell.alignment)def copy_row(sheet_src, sheet_dest, src_row_num, dest_row_num):src_row = sheet_src[src_row_num]for cell in src_row:dest_cell = sheet_dest.cell(row=dest_row_num, column=cell.column, value=cell.value)copy_cell_format(cell, dest_cell)# 复制行高sheet_dest.row_dimensi