• python post 参数


    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import urllib2
    import urllib
    import cookielib
    import json
    import httplib
    import re
    import requests
    from lxml import etree
    import StringIO
    import time
    import sys
    import json
    import re
    s = requests.session()
    print s.headers
    username='xxx'
    password='65c1978850b7dca18503d8e22073bab0'
    login_url = 'http://1.1.1.1/api/logincheck?password=%s&username=%s' %(password,username)
    print login_url
    data = {'username':username,'password':password}
    print data
    #data = urllib.urlencode(data)
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0'

         }
    response = s.get(login_url, data=data, headers=headers,timeout=10)
    print  response
    print '--------------------'
    print response.status_code
    a= response.content
    print a
    print type(a)
    p=re.compile('.*?<token>(.*?)</token>*')
    m=p.match(a)
    token= m.group(1)

    disable_url='http://1.1.1.1/api/ALERT-SERVICE/v1.0/alertExcludes?series_id=1&user_id=%s' %(username)
    print disable_url
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',
        'token':token,
        'Content-Type':'application/json;charset=utf-8'
         }
    data = {'userId':username,'classId':3,'className':'可用性监控','excludeId':'378','excludeMode':'1','excludeReason':'null','excludeTime':'yyyy-mm-dd-00-00-00~yyyy-mm-dd-23-59-59','set':'true','systemId':'9103','systemName':'AAAA'}
    print data
    #data = urllib.urlencode(data)
    print data
    response = s.put(disable_url, data=json.dumps(data), headers=headers,timeout=10)
    print response.content
    getstatisurl='http://1.1.1.1/api/ALERT-SERVICE/v1.0/alertExcludes?series_id=1&userId=%s&user_id=%s' %(username,username)
    print getstatisurl

  • 相关阅读:
    Windows CMD中 find命令(字符串查找)
    网络地址转换静态NAT
    网络地址转换静态NAT
    Android 的暗示 hint 用法
    Android 的暗示 hint 用法
    SQL Server 扩展事件
    SQL Server 扩展事件
    SqlServer中Exists的使用
    SqlServer中Exists的使用
    数据库还原,System.Data.SqlClient.SqlError: 因为数据库正在使用,所以无法获得对数据库的独占访问权。
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348816.html
Copyright © 2020-2023  润新知