def login(email, password):
payload = {'form_type':'customer_login', 'customer[email]': email,
'customer[password]': password}
session = requests.Session()
session.post('http://kith.com/account/login', data=payload, headers=
{"Referer": "https://kith.com"})
r = session.get('http://kith.com/account')
soup = BeautifulSoup(r.content, 'lxml')
print(soup.prettify())
login(email, password)
您好。有人可以帮忙吗?我无法登录帐户。刚刚熟悉请求模块,我不知道发生了什么。我的电子邮件和密码是正确的和标题。发布数据也是正确的。这是一些有用的代码(如下所示)。只是想知道为什么上面的代码不会让我登录。
def login():
with requests.Session() as c:
url = ('https://kith.com/account/login')
Username = '<email address here>'
Password = '<password here>'
c.get(url)
DATA = {'form_type':'customer_login','customer[email]':Username,'customer[password]':Password, }
c.post(url, data=DATA, headers={"Referer": "https://kith.com"})
page = c.get('https://kith.com/account')
print(page.content)
登录()