python接口自动化-post请求4

云盘登录实操案例:

python接口自动化-post请求4_第1张图片

python接口自动化-post请求4_第2张图片

 

代码参考:

# coding:utf-8
import requests
'''
https的请求相对于http安全级别高,需要验证SSL证书
import urllib3  使用这个方法就OK了
urllib3.disable_warnings()  忽略警告
'''
import urllib3
urllib3.disable_warnings()

url = "https://passport.baidu.com/v2/api/?login"

h = {
    "Connection": "keep-alive",
    "Content-Length":"2099",
    "Cache-Control": "max-age=0",
    "Content-Type": "application/x-www-form-urlencoded",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit"
                  "/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;"
              "q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Referer": "https://eyun.baidu.com/enterprise/login",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cookie": "BAIDUID=7605FAFE78F0A541B5142657082E0D65:FG=1;"
              " BIDUPSID=7605FAFE78F0A541B5142657082E0D65; PSTM=1543506941; "
              "HOSUPPORT=1; HISTORY=e95067aee7e0; "
              "Hm_lvt_90056b3f84f90da57dc0f40150f005d5=1545569276; "
              "pgv_pvi=8007264256; cart_id=359687424; "
              "BDORZ=FFFB88E999055A3F8A630C64834BD6D0; "
              "BDRCVFR[agrVmFYpr5c]=zJBXpjieShnn1nLn1nLQhPW; "
              "delPer=0; H_PS_PSSID=; PSINO=1; "
              "pplogid=34870FG8jD2IPDkTUhwI6A6uprEISWVi443O7%2FE6Mrexnqw%3D;"
              " UBI=fi_PncwhpxZ%7ETaJc%7E4n3zImJAkCrsX47meeVbT"
              "289RsGkZEH7nNQHLAeQUBtO5hromDixokZ5cZM3VhSj9N"
    }

body = {
        "apiver": "v3",
        "callback":	"parent.bd__pcbs__v9db0t",
        "charset": "UTF-8",
        "crypttype": "12",
        "detect":"1",
        "ds":"sR0/FGEVPesjIpfX60h7rssSOnm0PWQagJPC/"
             "cL6WGGjoOSUwxZBMGi3+Z9IdoJQjg6jIJWsRPXU/Hjarq/"
             "zua2Of1ENwh2OWG1Tomw2Rzcf/up984AuSm7hfrGGaodNB/"
             "j9j4i803AqzF2XK+gKyz/UJGUJBXrKfbpwlFVI6KqS1yp1By1"
             "SMkuer1JuLzELvGi1xJFsSSfR4wcXMOgriEfEdjmf16SlqwO"
             "tMA95en1c9WCVxbfgIDAINzmuzjbMM/dXo+pBXtuS/LBicM"
             "WrwohD6mhqJJCPYjxZrZ0CezrDWN9haVBpm+CM0X/e7GoNF"
             "Kcst/0sYno7ap1Hoh03dccHkMaal2c6K709YDonWpL1mcsx"
             "ailWP4bl5vii3Cml2l9NlYmFTeMpCQkrTz0T4JY9fIiLZFEha"
             "oAFeKEqi+G5IUy32dP00Td5rq6uhAf8a/jZjKS5/1Ya/5oRkFvj"
             "n/YM5g0HgE/9U7QPNXyw2ygtiOG2EQ15pB/BfQjSVrl2K3kBa7VEIN"
             "vBrI/RCt7CAr0K8odk+S2FfytD9xsU1iericwswfESrUVnw236vjUkjR8"
             "tfIYJu6lqZ3Jq5jXI9NuS9d7h7Ua0O+LxBL4fRK8=",
        "dv":"tk0.230653410420984751553417149773@rr"
             "p0AyAkFY6m-8v8Zs8FpAMbcv8bhRApcRPMA3QFZOJK8Y6w"
             "Q~AMjbATjjnpuhtFPDv8bRMbht8pg~MbcbQWBUtEpSIDj~AtVUR"
             "k8WnkqYBop4ub5htBcR8pAvMwuRMzBwIM549Kb3nkvzA1hgAt9Y6m-8v8Zs"
             "8FpAMbcv8bhRApcRPMA3QFZOJK8YAtr-4Mjb6DjjnpuhtFPDv8bRMbht8pg~MbcbQ"
             "WBUtEpSIDjW4trbRq__lpdA19-nkozAmj-619Z4D-g6t6WADjw6wqY61vw6tVYRq__yqqLzq"
             "Cc4~3QhCpi6DjUnkQjIptP2Yjn1rw6k9b6wv-6kvU6kFfAkQb6"
             "t8b6wv-Awo~4tQz6j__ip0EqLsu~Qs6"
             "HnUc3GMBenE5OLKubnEAiJDc3JXu3QXhULMA3nW-iIW3ensBeI2BELKZ3Iq__Fp"
             "t6mjjnkowAtvY4tFUnkowA19YAw9fnkowA19Y6t6WATjz61V_",
        "gid":"72C30AA-9369-4682-99FD-5399DB87CB17",
        "loginmerge":"true",
        "logintype":"basicLogin",
        "logLoginType":"pc_loginBasic",
        "mem_pass":"on",
        "password":"R/vJSYn5VZPokvhYExIkVZdPejZIR+OQ5NGS9kcPMfhN8TBDr"
                   "NuJsiBBJFd6oGgThBPuJLBwj2FsvswiHwXPjUGUYl83hQtGH/l"
                   "KmTtHC7/mzpq+OL2WsKvHRV8x0rdHMZVN52nCG/O7p6No"
                   "j4FOtXfma6ICMjx62msymgBaYuw=",
        "ppui_logintime":"28625",
        "quick_user":"0",
        "rsakey":"gjtRSpU3BQI3TnhSgX4iyCFVdbwy7wjA",
        "safeflg":"0",
        "staticpage":"https://eyun.baidu.com/box-static/"
                     "business-base/widget/passAPI/pass_v3_jump.html",
        "subpro":"netdisk_web",
        "tk":"34870FG8jD2IPDkTUhwI6A6uprEISWVi443O7/E6Mrexnqw=",
        "token":"2a32c3a035680b3c00318a3cbe7bdd93",
        "tpl":"cloudforbusiness",
        "traceid":"E82D0501",
        "tt":"1553417177776",
        "u":"https://eyun.baidu.com/enterprise/login",
        "username":"188----2832(账户已更改)",
}

r = requests.post(url, data=body, headers=h, verify=False)

print(r.status_code)
print(r.url)
print(r.text)

  

返回的结果:

F:\test-req-py\venv\Scripts\python.exe F:/test-req-py/day2/t3.py
200
https://passport.baidu.com/v2/api/?login









  

 

转载于:https://www.cnblogs.com/JodieRao/p/10589076.html

你可能感兴趣的:(python接口自动化-post请求4)