qinling072 发表于 2018-8-15 12:46:33

需要auth验证的post请求(python)

#!/usr/bin/python3.5  
#
  

  
import sys, requests
  

  
try:
  
    host = sys.argv
  
except IndexError:
  
    sys.exit('Usage: {0} host'.format(sys.argv))
  

  
user = 'root'
  
passwd = '123'
  

  
url = 'http://{0}/xcache/cacher/'.format(host)
  
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
  
            'Referer':'http://{0}/xcache/cacher/'.format(host),
  
         }
  
payload = {'type':'0', 'cacheid':'0', 'clearcache':'%E6%B8%85%E9%99%A4'}
  
result = requests.post(url, headers=headers, data=payload, auth=(user, passwd))
  
if result.status_code == 200:
  
    print('clear cache success')
  
else:
  
    print(result.status_code)
页: [1]
查看完整版本: 需要auth验证的post请求(python)