上线产品的登录接口会有验证码,一般可以通过添加cookie的方式绕过验证码。
一、抓登录的cookie
1. 先手动登录一次,然后用fiddler抓取这个cookie,再直接把这个值添加到cookies或请求头部中
二、举例
1. 方式一:
import requests
cookie={'JSESSIONID':'EAD1309FD6AB97D3F4BADCA2CC1CC4CC','bjui_theme':'blue','_jfinal_captcha':'68fd6293b09f5d4626de310e2871f714'}
rrr=requests.post('http://999.999.999.999/admin/unable?id=132346&unable=1&deviceSerial=18150120',cookies=cookie)
print(rrr.text)
2. 方式二:
import requests header={'Accept':'application/json, text/javascript, */*; q=0.01',\ 'User-Agent':'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'} header['cookie']='JSESSIONID=EAD1309FD6AB97D3F4BADCA2CC1CC4CC; bjui_theme=blue; _jfinal_captcha=68fd6293b09f5d4626de310e2871f714' rrr=requests.post('http://999.999.999.999/admin/unable?id=132346&unable=1&deviceSerial=18150120',headers=header) print(rrr.text)