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
#3
(Sep-23-2020, 09:42 AM)snippsat Wrote: 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.

Selenium is too slow for me. That's why I try to write this with requests
Reply


Messages In This Thread
RE: Problem with logging in on website - python w/ requests - by GoldeNx - Sep-23-2020, 12:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting content from a website using Python? SandraYokum 4 614 Jun-18-2024, 07:57 AM
Last Post: Larz60+
  Problem with scrapping Website giddyhead 1 1,815 Mar-08-2024, 08:20 AM
Last Post: AhanaSharma
  Retrieve website content using Python? Vadanane 1 1,458 Jan-16-2023, 09:55 AM
Last Post: Axel_Erfurt
  POST requests - different requests return the same response Default_001 3 2,107 Mar-10-2022, 11:26 PM
Last Post: Default_001
  I want to create an automated website in python mkdhrub1 2 2,658 Dec-27-2021, 11:27 PM
Last Post: Larz60+
  Python to build website Methew324 1 2,356 Dec-15-2020, 05:57 AM
Last Post: buran
  Scraping all website text using Python MKMKMKMK 1 2,209 Nov-26-2020, 10:35 PM
Last Post: Larz60+
  Python Webscraping with a Login Website warriordazza 0 2,745 Jun-07-2020, 07:04 AM
Last Post: warriordazza
  How to perform a successful login(signin) through Requests in Python Kalet 1 2,470 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  Python tool based on website? zarize 2 2,585 Mar-21-2020, 02:25 PM
Last Post: zarize

Forum Jump:

User Panel Messages

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