Python Forum
Problem with logging in on website - python w/ requests
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with logging in on website - python w/ requests
#1
Hello,
I'm learning how to write requests in python. I'm trying to log in to zalando-lounge.pl website. I keep recieving 403 error. I passed all the headers and it still doesn't work.

That's my code:
import requests
import re
from bs4 import BeautifulSoup
 
session = requests.Session()
 
login_data = {
   'email':'[email protected]',
   'password':'mypasswordexample',
   'onlyLogin':'true'
}
 
mainPage = 'https://www.zalando-lounge.pl/#/login'
loginPage = 'https://www.zalando-lounge.pl/onboarding-api/login'
productPage = 'https://www.zalando-lounge.pl/campaigns/ZZO124A/categories/136197597/articles/ZZLNME013-Q00'
 
 
main_page = session.get(mainPage)
print(main_page.status_code)
cookie = session.cookies.get_dict()
cookie = re.sub("'", '', str(cookie))
cookie = re.sub(": ", "=", cookie)
cookie = re.sub(",",";", cookie)
cookie = re.sub("{", "", cookie)
cookie = re.sub("}", "", cookie
cookie = cookie+"; G_ENABLED_IDPS=google"
print(cookie)
 
headers = {
    'authority': 'www.zalando-lounge.pl',
    'path': '/onboarding-api/login',
    'scheme': 'https',
    'accept': '*/*',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7',
    'content-length': '83',
    'content-type': 'application/json',
    'cookie': cookie,
    'origin': 'https://www.zalando-lounge.pl',
    'referer': 'https://www.zalando-lounge.pl/',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
}
 
login_process = session.post(loginPage, data=login_data, headers=headers)
print(login_process.status_code)
print(session.cookies.get_dict())
 
product_page = session.get(productPage, headers=headers)
source_code = product_page.content
soup = BeautifulSoup(source_code, "html.parser")
xd = soup.find_all("span")
print(xd)
That's how my random cookie string looks like:

Zalando-Client-Id=67a554d4-6e24-4add-9537-2a0126c23aff; _abck=2707BF125938F7009191BAB069D39FFE~-1~YAAQNb17XMn+w7F0AQAAZ7WMsgQm+rbBeYpB3zcMq4l/hfZv58CeR4gKnKRf0hKQNVa7x7GNVrlhGoXrOiQ/bQ4CT9zfsp0MR0KLEZ9ZF56qhNzK7HBu8yfYbLkGB73COwUPpErpArOQtcSRNBLj06LBXBm6zhG+o4oAnQIiJstmMTNH8LXXZMxfXi+CjKQfVmYl/VF7JRyfz2x/f4ZrJ9NVRiH1Y9KN7sQo5wu9dJb4g/TsNIWARmfiKWKQP15xVXP8ymnedUTc2YhILmRmJdWyc+5QH7qMt1yzYpmY4iVz/Svm/MEoVxaSU4RUJocd1g==~-1~-1~-1; bm_sz=20B9BCDB198389EC02111957222E7E46~YAAQNb17XMj+w7F0AQAAZ7WMsgljGBLIRyR4lwG8R3FdEv3aJiK/dXikpp4MEw5B9j1UJBw7ZQ0fUnibdCbiSwIBXiOLKmKv9shq9uad3qm8WISRq+K1JqcS6KLzKEF8Wdwt48CaeE/kLaUnG0IVQXtfcr4pTuAWtgBpvidZfkRxOiV0gFTBopqPN9E2MgnNvotBGmx6Vg==; frsx=AAEAACY1shlbU3xPQ-ZOqAl1rdpCFsRcDGs0DShk4y0q--8KEeR4tsHG-b1Kedj8K6aRvugNyUZkeJnaho_NSI0iLlbCWWbr34AvyT-05JCY3v5oLJu39aTQO5RdmYSBZ0Lda7PgHUak9DeLqTWbP27iPxbBY3QQf3GD1vxfXfGE64d6Bcp2wqk1DnVsERFrWRF0SChCzt_6G0scIdsonOw=; zl_acquire_modal_version=v2; zl_webview_appversion=; zl_webview_ga_cid=; zl_webview_ga_tid=; zl_webviewos=; G_ENABLED_IDPS=google
And that's how the request headers look when I log in to the website using browser: https://i.stack.imgur.com/NxzfP.png

Could you tell me what am I doing wrong? Thank you in advance
Reply


Messages In This Thread
Problem with logging in on website - python w/ requests - by GoldeNx - Sep-22-2020, 09:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with scrapping Website giddyhead 1 1,634 Mar-08-2024, 08:20 AM
Last Post: AhanaSharma
  Retrieve website content using Python? Vadanane 1 1,272 Jan-16-2023, 09:55 AM
Last Post: Axel_Erfurt
  POST requests - different requests return the same response Default_001 3 1,951 Mar-10-2022, 11:26 PM
Last Post: Default_001
  I want to create an automated website in python mkdhrub1 2 2,429 Dec-27-2021, 11:27 PM
Last Post: Larz60+
  Python to build website Methew324 1 2,242 Dec-15-2020, 05:57 AM
Last Post: buran
  Scraping all website text using Python MKMKMKMK 1 2,092 Nov-26-2020, 10:35 PM
Last Post: Larz60+
  Python Webscraping with a Login Website warriordazza 0 2,609 Jun-07-2020, 07:04 AM
Last Post: warriordazza
  How to perform a successful login(signin) through Requests in Python Kalet 1 2,352 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  Python tool based on website? zarize 2 2,494 Mar-21-2020, 02:25 PM
Last Post: zarize
  Scraping problems with Python requests. gtlhbkkj 1 1,885 Jan-22-2020, 11:00 AM
Last Post: gtlhbkkj

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020