python代码实现http get请求curl -u 用户名:密码 url -X get
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | #curl -u debezium:4a3s4d02234h http://p-awsbj-sas-hadoop-debezium-001.mynextev.net:8083/connectors -X GET import requests s = requests.session() s.auth = ('debezium','4a3s4d02234h') url = 'http://p-awsbj-sas-hadoop-debezium-001.mynextev.net:8083/connectors' # s = json.dumps({'key1': 'value1', 'key2': 'value2'}) # r = requests.post(url, data=s) # print(r.text) r = s.get(url) #打印response print(r) #获取状态码 print(r.status_code) #获取请求的数据 data = r.json() print(data) #获取请求内容 text = r.text print(text) |