def applyChannels(): params = {"count": 20} timestamp = mytoken.getTime() token = mytoken.gen_token(spiderId, secret, params, timestamp) apply_headers = mytoken.genHeaders(token, spiderId, timestamp) try: r = requests.get( "http://api.xdaili.cn/xdaili-api/spider/applyChannels", headers=apply_headers, json=params, timeout=120) except Exception as err_info: r = None print(err_info) if r is not None: print(r.status_code) if r.status_code == 200: print(r.content) print(r.json()) result = r.json() if result["ERRORCODE"] == "0" and result["RESULT"]: for one in result["RESULT"]: print(one) print(one["proxyId"]) print(one["orderno"]) getDynamicIP(one["orderno"], one["proxyId"])
# -*- coding:utf-8 -*- import requests from mytoken import gen_token spiderId = "7aff9cc6932d495484e9be4cd20cc158" //登录后在个人中心获取 secret = "915bd197de454c71a23b2589b4b6d6b5" //登录后在个人中心获取 logoutall_headers = gen_token(spiderId, secret) try: r = requests.get("http://api.xdaili.cn/xdaili-api/spider/logOutAll", headers=logoutall_headers, timeout=120) except Exception as err_info: r = None print(err_info) if r is not None: print(r.status_code) if r.status_code == 200: print(r.content)
# -*- coding:utf-8 -*- import requests import mytoken # 登录后在个人中心获取 spiderId = "8ea1baef1c3047ed83182b4a0d7ba5c9" secret = "0f5c79113f2f43fbae613382daac8297" params = {"map": {"433a83d2f96d11e9af127cd30abda612": "DD201911218432z9iG9r"}} #token通过token的计算方法生成,timestamp为生成token时所用的时间戳,在生成token的代码中可找到。 timestamp = mytoken.getTime() token = mytoken.gen_token(spiderId, secret, params, timestamp) headers = mytoken.genHeaders(token, spiderId, timestamp) r = requests.get("http://api.xdaili.cn/xdaili-api/spider/logOut", headers=headers, json=params) print(r.status_code) # 查看状态码 print(r.content) # 查看返回的数据 print(type(r.content)) # 查看数据类型 print(r.json()) # 相当于json.loads(r.content) print(r.json()["RESULT"]) # 获取结果
# -*- coding:utf-8 -*- import requests from mytoken import gen_token spiderId = "7aff9cc6932d495484e9be4cd20cc158" //登录后在个人中心获取 secret = "915bd197de454c71a23b2589b4b6d6b5" //登录后在个人中心获取 """ 申请拨号服务器 """ p = {"count": 20} apply_headers = gen_token(spiderId, secret, p) try: r = requests.get("http://api.xdaili.cn/xdaili-api/spider/applyChannels", headers=apply_headers, json=p, timeout=120) except Exception as err_info: r = None print(err_info) if r is not None: print(r.status_code) if r.status_code == 200: print(r.content) print(r.json()) result = r.json() if result["ERRORCODE"] == "0" and result["RESULT"]: for one in result["RESULT"]:
# -*- coding:utf-8 -*- import requests import mytoken # 登录后在个人中心获取 spiderId = "8ea1baef1c3047ed83182b4a0dsba5c9" secret = "0f5c79113f2f43fbae613d82daac8297" timestamp = mytoken.getTime() token = mytoken.gen_token(spiderId, secret, "", timestamp) logoutall_headers = mytoken.genHeaders(token, spiderId, timestamp) try: r = requests.get("http://api.xdaili.cn/xdaili-api/spider/logOutAll", headers=logoutall_headers, timeout=120) except Exception as err_info: r = None print(err_info) if r is not None: print(r.status_code) if r.status_code == 200: print(r.content) print(r.json())