Automate Chouti Login and Upvote with Selenium and Cookies

This tutorial walks you through using Selenium to automatically log into the Chouti website, extract authentication cookies, and programmatically send upvote requests, complete with preparation steps, mechanism explanation, code snippets, and visual results.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Automate Chouti Login and Upvote with Selenium and Cookies

Preparation

Before starting, ensure you have ChromeDriver (a headless Chrome browser driver) and Selenium installed. Selenium simulates user actions such as clicking, typing, and dragging, and is often used to bypass anti‑scraping measures.

Chouti Upvote Mechanism

Upvoting on Chouti requires a logged‑in session. After logging in, the server stores authentication data in a cookie. By reusing this cookie, subsequent upvote requests can be sent without invoking Selenium again.

Login Pre‑heat

The Chouti homepage ( https://dig.chouti.com/ ) displays a login button at the top right. Clicking it opens a modal dialog where credentials are entered.

Automated Login

Because the login button resides in a modal, Selenium cannot click it directly; JavaScript execution is required. The script injects JavaScript to trigger the click event, fills in the credentials, and submits the form.

Cookie Extraction

After a successful login, Selenium’s get_cookies() method may not retrieve the full set, so JavaScript is used to read document.cookie and store it locally for later HTTP requests.

Finding the Upvote API

By clearing the browser’s network log and clicking the upvote button on an article, the POST request URL and payload can be observed. The payload contains a linkid (e.g., 29213534), which is the article’s unique identifier.

Code Implementation

The script combines the extracted cookie with the identified linkid and sends a POST request to the upvote endpoint. Sample code snippets are shown in the images below; the full script is available on GitHub.

Results

Running the script on the first ten articles successfully registers upvotes without further manual interaction. Animated GIFs demonstrate the automated login and upvote process.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonSeleniumCookieWeb Automation
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.