Skip to main content

158 posts tagged with "python"

python tag description

View All Tags

How to Detect Google AdSense on a Website with Python

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Detecting whether a website is running Google AdSense is a common task for digital marketers, SEO researchers, and competitive analysts. From a technical perspective, AdSense works by injecting a specific JavaScript library into the page, usually accompanied by a unique "Publisher ID" (formatted as pub-xxxxxxxxxxxxxxxx).

In Python, we can identify these markers by "scraping" the HTML and searching for the signature AdSense scripts.

How to Download YouTube Thumbnails in Python (Without Pytube)

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Downloading a YouTube thumbnail is a classic Python task that involves two main steps: extracting the unique Video ID from a URL and then fetching the image from Google's thumbnail servers.

Because YouTube uses a predictable URL structure for its images, you don't actually need the heavy pytube library just to get the thumbnail-standard requests will do the trick!

Pydantic for JSON Validation in Python

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

In our last article(python simpleeval examples), we built a dynamic rules engine using simpleeval. But there is a golden rule in software engineering: Garbage In, Garbage Out.

If your rules engine expects a checkout cart to have a cart_total (a number) and a user_role (a string), but the frontend accidentally sends {"cart_total": "free", "role": null}, your engine will crash. Before untrusted JSON data ever reaches your core logic, it needs to pass through a strict gatekeeper. In modern Python, that gatekeeper is Pydantic.

Analyzing YouTube Comment Sentiment with Python

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Analyzing the "vibe" of a YouTube comment section is a fantastic way to use Python for data science. Since yt-dlp doesn't always handle large-scale comment scraping easily, we'll use the YouTube Data API v3 (the official way) and the TextBlob library to perform the sentiment analysis.

This script will tell you if the first 100 commenters are mostly happy, angry, or neutral.

Get Youtube Video Metadata with Python (yt-dlp)

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

While simply grabbing a thumbnail only requires a basic URL trick, accessing a video's metadata-like its title, view count, and description-requires a tool that can "scrape" or "query" the actual page data.

In the Python world, the gold standard for this is yt-dlp. It is a faster, more frequently updated successor to the original youtube-dl. Unlike the official Google API, yt-dlp doesn't require an API key or complex project setup, making it perfect for quick scripts.

SimpleEval with Examples

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

While simpleeval is great for basic calculators, its true power shines in production environments where you need to let users define their own logic-like setting up custom alerts, dynamic pricing discounts, or conditional triggers-without exposing your server to malicious code execution.

Reasons to use dataclass over pydantic basemodel

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

While Pydantic is the industry standard for external data (APIs, JSON parsing), Python's built-in dataclasses are often the better choice for internal data.

To answer your specific questions:

  1. Is it speed? YES. Dataclasses are significantly faster at creating objects (instantiation).
  2. Is it strict data type? NO. Pydantic is stricter. Dataclasses do not validate types at runtime; they blindly accept whatever you give them.

Here are the 4 most convincing reasons to use Dataclasses over Pydantic in a modern app, with examples for each.

Generating Stylized QR Art with Stable Diffusion & ControlNet

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Gone are the days of boring black-and-white squares! With the advent of advanced AI image generation models like Stable Diffusion, we can now create QR codes that are not only scannable but are also stunning works of art. This guide will walk you through the process of generating stylized QR codes that seamlessly blend into captivating images.

Building a URL Redirector in Python for Dynamic QR Codes

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

If you print 1,000 posters with a QR code and the website URL changes next week, a "Static" QR code becomes a pile of wasted paper. The solution is a Dynamic QR code.

Instead of encoding your final destination (like myshop.com/promo-january), you encode a "Short URL" that you control (like myqr.link/offer). When a user scans it, your server looks up where offer should go today and redirects them instantly.

Exporting Python Barcode Scan Data to CSV and Excel

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Exporting your scan data is the final piece of the puzzle. While a database is great for storage, most team members prefer to see results in a spreadsheet.

In Python, the pandas library is the gold standard for this. It can read directly from your SQLite database and convert that data into a professional-looking Excel or CSV file in just a few lines of code.