ネットワーク要求のpythonを操作します

インポート要求

GET请求
URL = 'http://api.nnzhp.cn/api/user/stu_info'
データ= { 'stu_name': 'wyj'}
RES = requests.get(URL、データ)の.text
プリント(RES)

 

ポスト请求
URL = 'http://api.nnzhp.cn/api/user/login'
データ= { 'ユーザ名': 'niuhanyang'、 'passwdの': 'aA123456'}
RES = requests.post(URL、データ) .json()
プリント(RES)

 

入参是JSON
URL = 'http://api.nnzhp.cn/api/user/add_stu'
データ= { "名": "wyj"、 "グレード": "1"、 "電話":13212345611}
RES = requests.post(URL、JSON =データ).json()
プリント(RES)

 

需要クッキー
URL = 'http://api.nnzhp.cn/api/user/gold_add'
データ= { "stu_id": "100000150"、 "ゴールド":100}
クッキー= { "niuhanyang": "0a6c1aacd55500e5c20a0ad95e7a099c"}
RES = requests.post(URL、データ、クッキー=クッキー).json()
プリント(RES)

 

需要ヘッダ
URL = 'http://api.nnzhp.cn/api/user/all_stu'
ヘッダ= { 'リファラー': 'のhttp://api.nnzhp.cn/'}
RES = requests.get(URL、ヘッダー=ヘッダ).json()
プリント(RES)

 

転送サーバへのファイルの
URL = 'http://api.nnzhp.cn/api/file/file_upload'
データ= { 'ファイル':オープン( '123.py')}
RES = requests.post(URL、ファイル=データ).textの
印刷(RES)

 

 

おすすめ

転載: www.cnblogs.com/wangyujian/p/11803871.html