Python执行Exchange PowerShell命令
摘要:#pip install pypsrp from pypsrp.powershell import PowerShell, RunspacePool from pypsrp.wsman import WSMan host = 'ex01.test19.com' username='test19\\u
阅读全文
posted @
2024-08-12 17:58
momingliu11
阅读(64)
推荐(0) 编辑
Python3禁用AD账号与重置AD账号密码ldap
摘要:Python3禁用AD账号 # LDAP服务器地址、端口号及连接参数 import ldap3 from ldap3 import Server, Connection,ALL import datetime print(datetime.datetime.now()) server = Serve
阅读全文
posted @
2024-07-16 16:29
momingliu11
阅读(142)
推荐(0) 编辑
Python调用Graylog APi 分析401错误登录日志
摘要:ret_lst处理完成后是一个list,内容如下: [{'c_ip': '10.10.202.139', 'uname': 'ee'}, {'c_ip': '10.10.202.139', 'uname': 'tt'}, {'c_ip': '192.168.195.131', 'uname': 'e
阅读全文
posted @
2024-04-30 16:07
momingliu11
阅读(68)
推荐(0) 编辑
Python发送企业微信消息
摘要:给某个用户发送文本消息 #! /usr/bin/env python # -*- coding: UTF-8 -*- import requests, sys class SendWeiXinWork(): def __init__(self): self.CORP_ID = "ww2w" # 企业
阅读全文
posted @
2024-04-13 00:14
momingliu11
阅读(384)
推荐(0) 编辑
Python3.6升级到3.9
摘要:1.升级openssl到1.1.1n cd /data/softwares cd openssl-1.1.1n ./config make && make install ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln
阅读全文
posted @
2023-08-24 17:39
momingliu11
阅读(944)
推荐(0) 编辑
pip安装whl制定下载源
摘要:pip3 install click_house -i https://pypi.tuna.tsinghua.edu.cn/simple/
阅读全文
posted @
2023-08-03 15:07
momingliu11
阅读(26)
推荐(0) 编辑
Python3通过cookie登录
摘要:import json,urllib.request,urllib.parse,http.cookiejar url_base = 'https://spam.forti.com/api/v1' url_admin = 'AdminLogin' data = {'name' : 'admin', '
阅读全文
posted @
2022-03-09 17:25
momingliu11
阅读(460)
推荐(0) 编辑
Python2.7升级pip失败解决办法
摘要:CentOS下通过 pip install --upgrade pip 升级pip版本失败,解决方法如下: Python2.7自带pip版本为8.1, pip install --upgrade pip总是报错 wget wget https://bootstrap.pypa.io/get-pip.
阅读全文
posted @
2021-12-29 14:22
momingliu11
阅读(686)
推荐(0) 编辑
Python3 Post Get API
摘要:import sys,urllib.request,urllib.parse,json,string class GetDeviceDataAPI(): def __init__(self,name,password): #定义主url、获取token的url,获取设备信息的url self.url
阅读全文
posted @
2021-12-05 00:35
momingliu11
阅读(135)
推荐(0) 编辑
pip指定安装源
摘要:pip3 install exchangelib -i https://pypi.tuna.tsinghua.edu.cn/simple 安装指定的包,并指定安装源 RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.e
阅读全文
posted @
2021-09-21 16:34
momingliu11
阅读(638)
推荐(0) 编辑
Python调用Jenkins接口批准/拒绝Pipeline流程
摘要:import jenkins,requests,urllib jenkins_server_url = 'http://jenkins.jk.com/' user_id = 'approver' api_token = '1187e29' # api_token = 'password' job_n
阅读全文
posted @
2020-11-10 11:11
momingliu11
阅读(721)
推荐(0) 编辑
Python对json排序分组
摘要:res_dl是一个json字符串,如下: [{'time': '2020/8/10 12:37:29', 'url': 'http://www.baidu.com/Account/QrCodeLoginPost?returnUrl=127.0.0.1', 'ip': '120.229.137.87'
阅读全文
posted @
2020-08-12 18:33
momingliu11
阅读(1299)
推荐(0) 编辑
Python3下urllib.parse.urlencode()编码
摘要:zabbix_url="http://10.10.2.2/zabbix/api_jsonrpc.php"headers = {'Content-Type':'application/json'}auth_data = { "jsonrpc":"2.0", "method":"user.login",
阅读全文
posted @
2020-05-27 11:46
momingliu11
阅读(6196)
推荐(0) 编辑
Python2调用Salt API
摘要:#!/usr/bin/env python #coding=utf-8 #For Python2 import urllib,urllib2,json,sys,importlib,argparse reload(sys) sys.setdefaultencoding('utf-8') class s
阅读全文
posted @
2020-05-25 16:32
momingliu11
阅读(370)
推荐(0) 编辑
Python3调用Salt API
摘要:curl调用salt api cmd.run使用方法如下: curl http://10.10.2.11:8000 \ -H 'Accept: application/x-yaml' \ -H 'X-Auth-Token: 042a226e6'\ -d client=local \ -d tgt='
阅读全文
posted @
2020-05-20 18:15
momingliu11
阅读(1233)
推荐(0) 编辑
修改json文件
摘要:import os,json f = 'D:\\temp\\userlist.json' f2 = 'D:\\temp\\userlist2.json' file = open(f,'rb') fj = json.load(file) file.close() fj['liu'].remove('liu.ad3') fj['liu'].append('liu.ad4') # print...
阅读全文
posted @
2019-12-11 18:16
momingliu11
阅读(3131)
推荐(0) 编辑
Python对csv排序
摘要:#/usr/bin/evn python # -*- coding: utf-8 -*- import sys from operator import itemgetter # input_file = open(sys.argv[1]) input_file = open("D:\\tmp\\a.csv") output_file = open("D:\\tmp\\asorted.csv","
阅读全文
posted @
2019-11-15 17:01
momingliu11
阅读(3695)
推荐(0) 编辑