项目地址 https://github.com/etianen/django-python3-ldap LDAP django_python3_ldap 如果不添加cn查找用户会出现同步时出现如下报错: LDAP bind failed: LDAPInvalidCredentialsResult - 49 - invalidCredentials - None - None - bindResponse - None CommandError: Could not connect to LDAP server 添加admin Generic: Posix Group (posixGroup),并且增加password属性,用于登录查找,或者个人用户也可以 ### LDAP # The URL of the LDAP server. LDAP_AUTH_URL = "ldap://172.16.16.4" # Initiate TLS on connection. LDAP_AUTH_USE_TLS = False # The LDAP search base for loo.... Django 使用ldap认证细节 Python
#!/usr/bin/python # -- coding: utf-8 -- # @Time : 2020/12/14 13:07 # @Author : cuijianzhe # @File : xlwt.py # @Software: PyCharm import openpyxl import requests import os import random name = input('请输入表格名称:') path = name + '.xlsx' wb = openpyxl.load_workbook(path) sheetnames = wb.sheetnames #获取文件中所有的 sheet sheetData = wb[sheetnames[0]] #第一个 sheet 的内容 rows_max = sheetData.max_row #最大行数 cols_max = sheetData.max_column #最大列数 ApprovalNumber = sheetData.cell(row = 1,column = 4).value def get_case....... 表格数据提取 Python
根据时间星期几判断用哪张壁纸 # !/usr/bin/env python3 # -- coding:utf-8 -- import requests # import pywintypes import win32api import win32con import win32gui import os import datetime,time from PIL import Image def get_week_day(date): week_day_dict = { 0 : '星期一', 1 : '星期二', 2 : '星期三', 3 : '星期四', 4 : '星期五', 5 : '星期六', 6 : '星期天', } day = date.weekday() return week_day_dict[day] # print(get_week_day(datetime.datetime.now())) def getImages(): filepath = os.path.split(os.path.realpath(file))[0] # 本地目录路径 # pr.... 利用Python对windows桌面自动更换壁纸 Python
Django 3.1 官网学习路线 开始按照官网进行学习Django 框架 第一部分 安装 Django D:\Django_study>python -m django --version 3.1 创建项目 如果这是您第一次使用 Django,那么您必须进行一些初始设置。也就是说,您需要自动生成一些建立 Django 项目的代码——Django 实例的设置集合,包括数据库配置、特定于 Django 的选项和特定于应用程序的设置。 从命令行,cd 到您想存储代码的目录,然后运行以下命令: django-admin startproject Django_study 开发服务 python manage.py runserver 默认情况下,runserver 命令在端口 8000 的内部 IP 上启动开发服务器。 如果您想更改服务器的端口,请将其作为命令行参数传递。例如,这个命令在端口 8080 上启动服务器: python manage.py runserver 8080 如果您想更改服务器的 IP,请将其与端口一起传递。例如,要监听所有可用的公共 ip(如果你正在运行.... Django 3.1 官网学习路线 Python
以前用的好好的脚本,这几天一直报这个错。经过查询时证书验证的错误。 报错:requests.exceptions.SSLError: HTTPSConnectionPool(host='tc.ltyuanfang.cn', port=443): Max retries exceeded with url: /api/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))) 解决方法: login = requests.post(url=url_token, data=payload,verify=False).text 请求参数加上跳过验证:verify=False 然后,引入代码: import urllib3 urllib3.disable_warnings() requests.exceptions.SSLError: HTTPSConnectionPool Python
同步资产信息到Jumpserver Jumpserver开发文档: 创建API Key 阿里云API文档: 具体代码: 添加本地IDC机房服务器白名单,避免同步阿里云删除本地机房服务器资产 同步比较Jumpserver创建的重复资产 实时同步线上资产到Jumpserver 同步操作发送结果到钉钉消息 #!/usr/bin/env python3 #coding=utf-8 import json import requests import time from httpsig.requests_auth import HTTPSignatureAuth from aliyunsdkcore.client import AcsClient from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest from collections import Counter #新建jumpserver KEY_ID = 'KEY_ID' SECRET = 'SECRET' Ju.... 阿里云同步资产信息到Jumpserver Jumpserver
zabbix发送报警内容调用zabbix的api生成原始图数据,然后将图片上传到远方图床取出图片URL进行展示; #!/bin/env python3 import sys import requests import json import os import time import re url = 'http://192.168.51.202/api_jsonrpc.php' headers = {'Content-Type': 'application/json-rpc'} graph_path='/data/zabbix/images/' #定义图片存储路径 graph_url='http://192.168.51.202/chart.php' #定义图表的url loginurl="http://192.168.51.202/index.php" #定义登录的url def get_itemid(message): itemid = re.search(r'ITEMID:(\d+)',message).group(1) return itemid def get_im....... zabbix发送报警信息带图片 Linux
开启新生活 #!/usr/bin/python # -- coding: utf-8 -- # @Time : 2020/6/2 18:36 # @Author : cuijianzhe # @File : biaoge.py # @Software: PyCharm import xlrd import xlwt import time import os name = input('请输入表格名称:') path = name + '.xls' date = time.strftime('%Y-%m-%d',time.localtime()) workbook = xlrd.open_workbook(path) #列出所有表头 Data_sheet = workbook.sheets()[1] #表头参数 # print(Data_sheet.name) rowNum = Data_sheet.nrows #行数 ---419 # print(rowNum) colNum = Data_sheet.ncols #列数 --9 # print(colNum) ''' 提取单元格...... 表格数据抽取以及生成表格 Python
关于HTTP协议: 1. 浏览器往服务端发的叫 请求(request) 请求的消息格式: 请求方法 路径 HTTP/1.1\r\n k1:v1\r\n k2:v2\r\n \r\n 请求数据 2. 服务端往浏览器发的叫 响应(response) 响应的消息格式: HTTP/1.1 状态码 状态描述符\r\n k1:v1\r\n k2:v2\r\n \r\n 响应正文 <-- html的内容 HTTP请求响应步骤: 客户端连接到web服务器 发送http请求 服务器接收请求并返回http响应 释放tcp连接 客户端浏览器解析html内容 一个HTTP客户端,与web服务器的http端口建立一个TCP套接字连接 通过套接字,客户端向web服务器发送一个文本的请求报文,一个请求报文由请求头部、空行和请求数据4部分组成 web服务器解析请求,定位请求资源。服务器将资源副本写到TCP套接字,由客户端读取。一个响应由状态行、响应头部、空行就鞥相应数据4部分组成。 若connection模式为close,则服务器主动关闭TCP连接,客户端被动关闭连接,释放TCP连接.... 一个完整的请求流程 Python
按照指定长度和数量生成对应随机密码文件 import random ''' # 这里要用到random函数中的随机生成一个区间的整数 randint 函数模块 ''' def generate_code(code_len): all_char = '0123456789qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJIKOLP!@#$%^&*()><?' index = len(all_char) - 1 code = '' for _ in range(int(code_len)): num = random.randint(0,index) code += all_char[num] res = ''.join(code) return res count = input('请输入你要产生多少条密码:').strip() length = input('请输入你要产生密码的长度:').strip() for _ in range(int(count)): print(generate_code(length)) wit.... Python生成指定长度随机数密码文件 Python
获取北京城区天气信息 #!/usr/bin/python # -- coding: utf-8 -- # @Time : 2020/5/1 16:11 # @Author : cuijianzhe # @File : weather.py # @Software: PyCharm from datetime import datetime import urllib.request from lxml import etree def getWeather(): url = "http://www.weather.com.cn/weather/101010100.shtml" response = urllib.request.urlopen(url) html = response.read().decode() parseHtml = etree.HTML(html) temperatureLow = ''.join(parseHtml.xpath('//*[@id="7d"]/ul/li[1]/p[2]/i/text()')) # 获取今天最低温度 temperatureHi...... Pyhton爬虫爬取天气情况以及情话 Python
背景 公司直播间直播课程,有时会出现发题、金币刷新等卡顿问题,为了解释不是网络而是接口或者服务问题,此程序诞生。 因为不带多线程版本ping程序挂钩多个ip的话,容易出现时间缺失(如下),所以加上多线程,同时程序简化了很多…… ping参数自选 用法: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-c compartment] [-p] [-4] [-6] target_name 选项: -t Ping 指定的主机,直到停止。 若要查看统计信息并继续操作,请键入 Ctrl+Break; 若要停止,请键入 Ctrl+C。 -a 将地址解析为主机名。 -n count 要发送的回显请求数。 -l size 发送缓冲区大小。 -f 在数据包中设置“不分段”标记(仅适用于 IPv4)。 -i TTL 生存时间。 -v TO.... 用Python实现widows下ping程序 Python
API平台搭建 参考这里 我把api搭建在自己的服务器上了 docker pull binaryify/netease_cloud_music_api docker run -d -p 8090:3000 --name netease_cloud_music_api -e http_proxy= -e https_proxy= -e no_proxy= -e HTTP_PROXY= -e HTTPS_PROXY= -e NO_PROXY= binaryify/netease_cloud_music_api $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e25f4fc06c81 binaryify/netease_cloud_music_api "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:8090->3000/tcp netease_cloud_music_api 55a900b38684 b3l...... 利用Python实现网易云音乐自动签到 Python
选项一直都有 但我选择了你 之前写的对接飞书的接口发送消息,顺便爬取一下博客把文章title和link爬取出来集成到富文本中。 注意的是只能爬取solo的内置皮肤pingsu里面的文章 由于页脚去掉版权信息的原因,我又改了一版去识别当前solo使用的皮肤是哪两款…… import urllib.request from lxml import etree import re class solo(): def init(self,url): self.url = url self.Article_num = solo.get_ArticlesNums() def Theme(self): ''' 检测solo皮肤,为Casper的话返回值,否则为空字符串 :return: ''' response = urllib.request.urlopen(self.url) html = response.read().decode() theme = (re.search('Casper|Pinghsu', html)).group() return theme def get.... 利用爬虫爬取我的solo博客 Python
一、聊天室 基于 UDP 的聊天室 Server 端: import socket sk = socket.socket(type=socket.SOCK_DGRAM) #DGRAM datagram 数据报文 sk.bind(('127.0.0.1',8080)) while True: msg,addr = sk.recvfrom(1024) print(addr) print(msg.decode('utf-8')) info = input('>>>').encode('utf-8') sk.sendto(info,addr) sk.close() Client1: import socket sk = socket.socket(type=socket.SOCK_DGRAM) ip_port = ('127.0.0.1',8080) while True: info = input('cjz:') info = ('\033[32m来自Jianzhe的消息:%s\033[0m'%info).encode('utf-8') sk.sendto(info,ip_.... python的TCP、UDP小程序 Python
飞书开放平台 此文只是测试使用,后续可能对接应用平台。 自定义消息发送 #!/bin/python3 ####################################################### # This script is to send messages to Lijuan regularly # # Date: 2020-2-17 # # Author: cuijianzhe # # Email: 598941324@qq.com # ####################################################### import requests,json,sys mobiles=sys.argv[1] messages=sys.argv[2] def get_token(): data = {"app_id":"cli_xxxxxxxxxxx9d","app_secret":"YJJxxxxxxxxxxxxxxxxxxxxxxxxxxxxYUi"} headers = {"Content-Type": "application.... 利用飞书BOT发送消息 Python
需求 收到一个这样的需求:要求访问腾讯的一个服务,无论身在哪里,都必须通过制定 ip 访问此服务,因为公司之前的 VPN 是我搭的,领导找我做这个需求,但是 VPN 此事并没有能适配此需求,因为我的那个 VPN 只是针对内网服务才走 VPN 流量,而腾讯的相关服务需要走外网流量,而且出口 ip 这个时候需要被代理成指定 ip。所以此文章针对次任务做个记录。 Socks Server 5 搭建 下载软件 下载地址点这里 安装 *下载解压 yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel wget https://jaist.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz tar zxvf ss5-3.8.9-8.tar.gz -C /usr/local/src cd /usr/local/src/ss5-3.8.9 ./configure make && .... 搭建使用Socks Server 5 服务器 Linux