• python实现获取系统版本和mac信息上传到指定接口


    import os,platform,uuid,urllib.parse,urllib.request,json
    def BeforeSystemRequests():
        '''
        the systeminfo uploads to api of ..
        '''
        def get_system_version():
            system_name = platform.system()
            if system_name == 'Windows' and os.name == 'nt':
                system_machine = platform.platform().split('-')[0] + platform.platform().split('-')[1]
            elif system_name == 'Darwin':
                system_machine = 'Mac-os'
            else:
                system_machine = system_name
            return system_machine
    
        def post(url,data):
            data = urllib.parse.urlencode({'info':data}).encode('utf-8')
            req = urllib.request.Request(url,data)
            urllib.request.urlopen(req)
            return
        def index():
            apiUrl = 'http://www.apicloud.com/setSublimeInfo'
            systemInfo = {
                "system": get_system_version(),
                "uuid": hex(uuid.getnode())
            }
            try:
                systemInfo = json.dumps(systemInfo) 
                post(apiUrl,systemInfo)
            except Exception as e:
                print('exception is :',e)
            finally:
                pass
        try:        
            index()
        except Exception as e:
            pass   
    

      

  • 相关阅读:
    Apache httponly Cookie泄露

    shell脚本
    Linux与windows的文件系统结构
    使用rsync进行远程同步
    电子邮件服务
    httpd虚拟主机
    Enpass 基于 Mezzanine
    powershell: 生成随机字符串
    thinkPHP5.x 更新字段为 NULL
  • 原文地址:https://www.cnblogs.com/songqingbo/p/5504899.html
Copyright © 2020-2023  润新知