不保持連接的寫法:
import requests
def requests_post():
params = {
'text': 'xjq', 'test': '123'}
r = requests.post("https://192.168.4.1:9527/login", data=params, verify=False)
print(r.text)
params = {
'text': '123', 'xjq': 'abc'}
r = requests.post("https://192.168.4.1:9527/login", data=params, verify=False)
print(r.text)
if __name__ == '__main__':
requests_post()
保持連接的寫法:
import requests
def requests_post():
session = requests.session()
params = {
'text': 'xjq', 'test': '123'}
r = session.post("https://192.168.4.1:9527/login", data=params, verify=False)
print(r.text)
params = {
'text': '123', 'xjq': 'abc'}
r = session.post("https://192.168.4.1:9527/login", data=params, verify=False)
print(r.text)
if __name__ == '__main__':
requests_post()