我使用 http.client 登录设备的 Web Configurator。
使用网络浏览器登录设备: https ://210.61.209.4/ 用户名/密码:support/stackoverflow.com
使用 http.client 时,我从 Web 浏览器复制包含 Cookie 中的身份验证令牌的标头,它可以访问 Web Configurator。
import http.client
import ssl
conn = http.client.HTTPSConnection("210.61.209.4",context = ssl._create_unverified_context())
payload = 'username=support&pwd=stackoverflow.com&password=stackoverflow.com&pwd_r=&mp_idx=0'
headers = {
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
'sec-ch-ua-mobile': '?0',
'Upgrade-Insecure-Requests': '1',
'Origin': 'https://210.61.209.4',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://210.61.209.4/',
'Accept-Language': 'zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,vi;q=0.6,en-GB;q=0.5,zh-CN;q=0.4',
'Cookie': '_ga=GA1.1.135496395.1606126381; ext-ssidtabOpt=n%3A0; _gid=GA1.1.798827174.1620711592; authtok=3HvvXEP2eD7eS6LRFb39IUSjYH4MMMQbc0rxrIekdJuDXrckXS69UU3XCbjT+ISn; secuRtBannerClsCookie=login'
}
conn.request("POST", "/", payload, headers)
我被困在 http.client 如何从网页发送和获取身份验证令牌以进行登录访问。有没有人遇到同样的情况?
谢谢你,BR,