我试图使用库登录这个站点的请求,但是这些字段具有动态id,如:
<input id="df76922e-dd08-40bf-bc99-94bb7f67f10b.loginForm.username" maxlength="50" name="df76922e-dd08-40bf-bc99-94bb7f67f10b:username" value="" tabindex="1" class="mail inpRad" type="text">这是我的密码:
import requests
payload = {'?????': email, '?????': senha}
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Accept': '*/*',
'X-Requested-With': 'XMLHttpRequest'}
request = requests.post('"https://carrinho.submarino.com.br/CustomerWeb/pages/Login'
headers=headers,
data=payload)
print(resquest.text)是否可以使用任何其他库的请求进行登录?
此df76922e-dd08-40bf-bc99-94bb7f67f10b更改每个请求,但loginForm.username是静态的。
发布于 2016-01-28 04:49:05
因为它只是一个动态字段,所以您也可以使用regex来获得它:
import requests
import re
r = requests.get('https://carrinho.submarino.com.br/CustomerWeb/pages/Login')
m = re.search('id="(.*)\.loginForm\.username', r.content)
id = m.group(1)
payload = {id+':username': email, id+':password': senha}https://stackoverflow.com/questions/35052898
复制相似问题