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
#2
In general i think you need to use Selenium for heavy JavaScript sites like this.
Usually cookies send automatically in a session.
Here something i have done before.
import requests
from bs4 import BeautifulSoup

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
}

login_data = {
   'email':'[email protected]',
   'password':'mypasswordexample',
   'onlyLogin':'true'
}

with requests.Session() as s:
    s.post('https://www.zalando-lounge.com/#/login', headers=headers, params=login_data)
    # logged in! session cookies saved for future requests
    # print(s.cookies)  # Test
    response = s.get('Url inside')
    # cookies sent automatically!
    soup = BeautifulSoup(response.content, 'lxml')
    welcome = soup.find('something inside')
    print(welcome) 
So even the message that that combination username and password doesn't match,is done bye JavaScript in this case React.
Selenium is the easiest way,or need to really look into how site work and maybe catch Json/Ajax response.
Reply


Messages In This Thread
RE: Problem with logging in on website - python w/ requests - by snippsat - Sep-23-2020, 09:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with scrapping Website giddyhead 1 1,657 Mar-08-2024, 08:20 AM
Last Post: AhanaSharma
  Retrieve website content using Python? Vadanane 1 1,293 Jan-16-2023, 09:55 AM
Last Post: Axel_Erfurt
  POST requests - different requests return the same response Default_001 3 1,972 Mar-10-2022, 11:26 PM
Last Post: Default_001
  I want to create an automated website in python mkdhrub1 2 2,466 Dec-27-2021, 11:27 PM
Last Post: Larz60+
  Python to build website Methew324 1 2,253 Dec-15-2020, 05:57 AM
Last Post: buran
  Scraping all website text using Python MKMKMKMK 1 2,106 Nov-26-2020, 10:35 PM
Last Post: Larz60+
  Python Webscraping with a Login Website warriordazza 0 2,628 Jun-07-2020, 07:04 AM
Last Post: warriordazza
  How to perform a successful login(signin) through Requests in Python Kalet 1 2,370 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  Python tool based on website? zarize 2 2,511 Mar-21-2020, 02:25 PM
Last Post: zarize
  Scraping problems with Python requests. gtlhbkkj 1 1,899 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