<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hai Nam Intel]]></title><description><![CDATA[Hai Nam Intel]]></description><link>https://hainam-intel.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:12:10 GMT</lastBuildDate><atom:link href="https://hainam-intel.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Extracting & Normalizing Public Shopify Store Catalogs, Variant Pricing & Discount Depth in Pure Python]]></title><description><![CDATA[Benchmarking public Shopify storefronts — tracking SKU pricing changes, active compare_at_price discounts, vendor breakdowns, and out-of-stock variants…]]></description><link>https://hainam-intel.hashnode.dev/extracting-normalizing-public-shopify-store-catalogs-variant-pricing-discount-depth-in-pure-python</link><guid isPermaLink="true">https://hainam-intel.hashnode.dev/extracting-normalizing-public-shopify-store-catalogs-variant-pricing-discount-depth-in-pure-python</guid><category><![CDATA[webscraping ]]></category><category><![CDATA[Python]]></category><category><![CDATA[shopify]]></category><category><![CDATA[ecommerce]]></category><dc:creator><![CDATA[Hai Nam]]></dc:creator><pubDate>Wed, 02 Dec 2026 04:22:24 GMT</pubDate><content:encoded><![CDATA[<p>Benchmarking public Shopify storefronts — tracking SKU pricing changes, active <code>compare_at_price</code> discounts, vendor breakdowns, and out-of-stock variants — does not require spinning up Playwright or headless Chrome.</p>
<p>Every standard Shopify storefront exposes structured catalog endpoints over plain HTTPS (<code>GET /products.json?limit=250&amp;page=1</code>). The hard part in production is <strong>normalizing inconsistent variant payloads, computing clean discount percentages, and paginating safely without hitting rate limits.</strong></p>
<p>Here is the compact Python pattern I run inside a ~75 MB container to inspect public Shopify catalogs in under 2 seconds.</p>
<hr />
<h3>1. Variant Price &amp; Discount Normalization</h3>
<p>Inside <code>/products.json</code>, each product contains an array of <code>variants</code>, where <code>price</code> and <code>compare_at_price</code> are serialized as nullable strings (often <code>""</code> or <code>None</code>). Parsing safely with <code>Decimal</code> prevents floating-point drift when comparing catalogs:</p>
<pre><code class="language-python">from decimal import Decimal, InvalidOperation

def parse_decimal(value: str | float | int | None) -&gt; Decimal | None:
    if value is None or str(value).strip() == "":
        return None
    try:
        return Decimal(str(value).strip())
    except InvalidOperation:
        return None

def compute_discount_pct(price: Decimal | None, compare_at: Decimal | None) -&gt; float:
    if price is None or compare_at is None or compare_at &lt;= 0 or compare_at &lt;= price:
        return 0.0
    return round(float(((compare_at - price) / compare_at) * Decimal("100")), 1)
</code></pre>
<hr />
<h3>2. Bounded Async Pagination With Polite Jitter</h3>
<p>To audit larger catalogs without hammering origin servers:</p>
<ol>
<li>Cap <code>limit=250</code> per request (Shopify's native max page size) and stop immediately when <code>len(products) &lt; limit</code>.</li>
<li>Track seen product <code>id</code> values across pages in a <code>set</code> so mid-scrape catalog shifts never emit duplicates.</li>
<li>Clamp <code>max_pages</code> per run and enforce explicit <code>httpx.Timeout(connect=5.0, read=12.0)</code> with retry-on-<code>429</code> honoring <code>Retry-After</code>.</li>
</ol>
<hr />
<h3>3. Ready-to-Use Open-Source Tools &amp; Endpoints</h3>
<p>If you prefer testing the normalized JSON output directly or wiring it into n8n / AI agents:</p>
<ul>
<li><strong>Free n8n Starters, MCP Config &amp; Source Examples (MIT):</strong> <a href="https://github.com/chimsedinang9x/free-n8n-b2b-shopify-ai-workflows">https://github.com/chimsedinang9x/free-n8n-b2b-shopify-ai-workflows</a></li>
<li><strong>REST Endpoint (<code>GET /v1/shopify/products</code>, 50 free req/mo):</strong> <a href="https://rapidapi.com/HaiNam-fCcm3FyVW/api/unified-web-app-store-jobs-markets-intelligence">https://rapidapi.com/HaiNam-fCcm3FyVW/api/unified-web-app-store-jobs-markets-intelligence</a></li>
<li><strong>Browser Extension (Free Firefox Add-on for instant KPI preview):</strong> <a href="https://addons.mozilla.org/en-US/firefox/addon/shoppulse-shopify-spy/">https://addons.mozilla.org/en-US/firefox/addon/shoppulse-shopify-spy/</a></li>
</ul>
<p>Happy to discuss edge cases like multi-currency storefront formatting or variant availability flags in the comments!</p>
]]></content:encoded></item><item><title><![CDATA[Why I Replaced Headless Chrome With Pure HTTP Pipelines (Cut RAM From 600MB to 75MB in Production)]]></title><description><![CDATA[If you have ever deployed Playwright or Puppeteer scrapers into small cloud containers, you already know the painful pattern: a single Chromium instance…]]></description><link>https://hainam-intel.hashnode.dev/why-i-replaced-headless-chrome-with-pure-http-pipelines-cut-ram-from-600mb-to-75mb-in-production</link><guid isPermaLink="true">https://hainam-intel.hashnode.dev/why-i-replaced-headless-chrome-with-pure-http-pipelines-cut-ram-from-600mb-to-75mb-in-production</guid><category><![CDATA[Python]]></category><category><![CDATA[FastAPI]]></category><category><![CDATA[webscraping ]]></category><category><![CDATA[architecture]]></category><dc:creator><![CDATA[Hai Nam]]></dc:creator><pubDate>Wed, 02 Dec 2026 04:10:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ce1d461e24cde7f45e114/fc2bc39e-c32d-46c2-b613-8c46cd3103d4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have ever deployed Playwright or Puppeteer scrapers into small cloud containers, you already know the painful pattern: a single Chromium instance eats 350–800 MB of RAM, cold starts take 4–10 seconds, and an unexpected OOM kill drops half your worker queue.</p>
<p>In most B2B data and e-commerce monitoring pipelines, <strong>we do not actually need a visual browser engine</strong> — we only need structured payloads that already live in predictable places on the origin server.</p>
<p>Here is the exact HTTP-only architecture I used to run 20 specialized data extractors and a 12-endpoint FastAPI gateway comfortably inside a single-worker <strong>512 MB</strong> container (~75 MB steady-state RAM).</p>
<hr />
<h3>1. Where the Data Actually Lives (Zero DOM Rendering Needed)</h3>
<p>Before spinning up a browser binary, inspect what the page already exposes cleanly over plain TLS HTTP/2:</p>
<table>
<thead>
<tr>
<th>Target Domain</th>
<th>Slow Browser Approach</th>
<th>Fast HTTP-Only Source</th>
</tr>
</thead>
<tbody><tr>
<td>Public Shopify Stores</td>
<td>Render storefront DOM + scroll</td>
<td>Structured storefront <code>/products.json</code> pagination (<code>limit=250</code>)</td>
</tr>
<tr>
<td>Hiring Boards (Greenhouse, Lever, Ashby)</td>
<td>Render iframe / SPA job widgets</td>
<td>Official public ATS JSON endpoints per company slug</td>
</tr>
<tr>
<td>Domain Hygiene &amp; Security</td>
<td>Paid enrichment API</td>
<td>Direct RDAP JSON + <code>dnspython</code> TXT queries (<code>v=spf1</code>, <code>_dmarc</code>) + TLS socket <code>getpeercert()</code></td>
</tr>
<tr>
<td>News, Podcasts &amp; Research</td>
<td>Parse cluttered HTML feeds</td>
<td>Native RSS/Atom XML, Apple Lookup JSON, arXiv / Crossref / SEC EDGAR APIs</td>
</tr>
<tr>
<td>B2B Contact &amp; Tech Signals</td>
<td>Execute full client JS bundle</td>
<td>Lightweight HTML header/meta/script fingerprint scan + targeted <code>/contact</code> &amp; <code>/about</code> fetches</td>
</tr>
</tbody></table>
<p><strong>Real measured footprint comparison per worker:</strong></p>
<ul>
<li>Headless Chromium worker: ~350–800 MB RAM, 3–12s per request</li>
<li>Async <code>httpx</code> + <code>lxml</code> + <code>dnspython</code> worker: ~70–100 MB RAM, 0.3–2.5s per request</li>
</ul>
<hr />
<h3>2. Mandatory Guardrail: Blocking SSRF on User-Supplied URLs</h3>
<p>Whenever an extraction service accepts arbitrary <code>url=</code> or <code>domain=</code> query parameters from callers, leaving outbound HTTP unrestricted exposes internal cloud metadata (<code>169.254.169.254</code>) and loopback services (<code>127.0.0.1</code>).</p>
<p>A clean Fail-Closed SSRF validator resolves DNS records <em>before</em> connecting and rejects any non-global IP:</p>
<pre><code class="language-python">import ipaddress
import socket
from urllib.parse import urlparse

def assert_public_http_target(raw_url: str) -&gt; str:
    parsed = urlparse(raw_url if "://" in raw_url else f"https://{raw_url}")
    if parsed.scheme not in {"http", "https"} or not parsed.hostname:
        raise ValueError("Invalid HTTP/HTTPS URL")

    infos = socket.getaddrinfo(parsed.hostname, None, proto=socket.IPPROTO_TCP)
    for info in infos:
        ip = ipaddress.ip_address(info[4][0])
        if (
            ip.is_private
            or ip.is_loopback
            or ip.is_link_local
            or ip.is_multicast
            or ip.is_reserved
            or ip.is_unspecified
        ):
            raise ValueError(f"Blocked non-public address: {ip}")

    return parsed.geturl()
</code></pre>
<hr />
<h3>3. Single-Worker Memory Hygiene &amp; Proxy Auth</h3>
<p>To survive inside strict 512 MB free-tier containers without leaking memory:</p>
<ol>
<li><strong>Reuse a single <code>httpx.AsyncClient</code></strong> via FastAPI lifespan hooks instead of creating per-request connection pools.</li>
<li><strong>Enforce strict response size caps and timeouts</strong> (<code>connect=5s, read=12s</code>) so slow origins cannot pile up coroutines.</li>
<li><strong>Add short-lived in-memory TTL caching</strong> so duplicate requests within a burst window resolve in <code>&lt;5 ms</code>.</li>
<li><strong>Validate gateway proxy headers in constant time</strong> (<code>hmac.compare_digest</code>) and fail closed whenever configuration secrets are missing.</li>
</ol>
<hr />
<h3>Open-Source Starters &amp; MCP Config (MIT License)</h3>
<p>I published open-source workflow starters, a Python quickstart client, a free 25-company B2B verification sample, and an MCP Server JSON config for Claude Desktop / Cursor / Windsurf on GitHub:</p>
<ul>
<li><strong>GitHub Repository (MIT):</strong> <a href="https://github.com/chimsedinang9x/free-n8n-b2b-shopify-ai-workflows">https://github.com/chimsedinang9x/free-n8n-b2b-shopify-ai-workflows</a></li>
</ul>
<p>Feel free to reuse the SSRF validator or HTTP extraction patterns in your own pipelines — happy to answer architecture questions in the comments.</p>
]]></content:encoded></item></channel></rss>