Monday, January 15, 2024

Python script to automate login and extract cookie

 pip install requests

*****************create file*****************

import requests

url_login = "https://example.com/login" # Replace with the actual login URL url_after_login = "https://example.com/next" # Replace with the actual URL after login # Replace with your actual username and password payload = { "username": "your_username", "password": "your_password" } # Create a session to persist cookies session = requests.Session() # Perform the login response_login = session.post(url_login, data=payload) # Check if login was successful (replace '200' with the appropriate success status code) if response_login.status_code == 200: print("Login successful") # Perform the action after login (e.g., skip OTP) response_after_login = session.get(url_after_login) # Get the value of the desired cookie (replace 'cookie_name' with the actual cookie name) cookie_value = session.cookies.get("cookie_name") if cookie_value: print(f"The value of the cookie is: {cookie_value}") else: print("The desired cookie was not found.") else: print("Login failed.")

**********************************************

save login_script.py
python login_script.py

3 comments:

  1. Whenever I need trustworthy updates, I visit newsversa com. Newsversa never disappoints with in-depth reporting, accurate information, and diverse topics that cover everything from technology to politics, helping me stay informed and confident in the news I read daily.

    ReplyDelete
  2. The quality of content on newsstupid com is exceptional, offering readers accurate reporting and informative insights. I appreciate the effort the team puts into research, ensuring that every story delivers value and clarity for audiences interested in current events.

    ReplyDelete
  3. Visiting newstrout com has become a daily habit because the content is reliable, easy to navigate, and highly informative. The team’s dedication to quality journalism ensures readers always receive news that is accurate, engaging, and relevant to current events.

    ReplyDelete

Create a Digital Clock using HTML and JavaScript

Create a Digital Clock using HTML and JavaScript  <! DOCTYPE html> < html > < head > ...

Followers

Search This Blog

Popular Posts