This script automates the process of logging into a Deezer account to extract the arl session cookie. This cookie is often required for other applications or APIs that interact with Deezer services on your behalf.
The script uses Selenium to control a real web browser, ensuring it can handle modern web technologies like JavaScript, popups, and dynamic content.
Before you begin, ensure you have the following installed on your system:
- Python: Version 3.8 or newer is recommended.
- Google Chrome: The script is configured to use Chrome, so you must have it installed.
- A Deezer Account: You will need valid Deezer login credentials.
It is highly recommended to use a Python virtual environment to keep project dependencies isolated.
-
Clone the repository: Download all the project files onto your local machine.
-
Create and Activate a Virtual Environment: Open a terminal in your project folder and run:
# Create the virtual environment python -m venv venv # Activate it # On Windows: .\venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install Dependencies: With your virtual environment active, install the required Python packages:
pip install -r requirements.txt
-
Run the Script: Execute the script from your terminal:
python deezer_arl_scraper.py
-
Enter Credentials: The script will prompt you to enter your Deezer email and password. The password input will be hidden for security.
Please enter your Deezer credentials. Email: your_email@example.com Password (input hidden): -
Automation: A Chrome browser window will open and automatically perform the following steps:
- Navigate to the Deezer login page.
- Accept any GDPR/cookie consent popups.
- Enter your credentials and submit the form.
- Wait for the main page to load to confirm a successful login.
-
Get the Cookie: If the login is successful, the script will print the
arlcookie to your terminal and then close the browser.--- Success! --- Your Deezer arl cookie is: [a long string of characters will be printed here]
For faster testing, you can hardcode your credentials directly into the script.
- How: Open the script file and edit the
DEFAULT_EMAILandDEFAULT_PASSWORDvariables at the top. - Usage: When you run the script, simply press
Enterat the email and password prompts to use the hardcoded values. - Security Warning: This is a security risk. Never commit a file with your credentials to a public repository like GitHub. This feature is intended for local testing only.
- Timeout Error: If the script fails with a timeout error, it will automatically save a
debug_screenshot.pngfile. Check this image first. It will show you exactly what the browser was seeing at the moment of failure (e.g., an incorrect password error, a new popup, a CAPTCHA, etc.). - Script Stops Working: Websites like Deezer frequently update their design. If this script suddenly stops working, it is likely because the HTML structure of the login page has changed. You will need to use your browser's Developer Tools (F12) to find the new
data-testidor other selectors for the input fields and buttons, and then update them in the script.