<?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[SpellzCode notes]]></title><description><![CDATA[SpellzCode notes]]></description><link>https://spellzcode.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 18:45:47 GMT</lastBuildDate><atom:link href="https://spellzcode.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[102 EU compliance questions we had never seen: our law index found the article first 76 times, a web search API 34]]></title><description><![CDATA[Yesterday we published a small test: 20 EU compliance questions, our EU law search against Exa's web search. Fair criticism of a 20-question test is that…]]></description><link>https://spellzcode.hashnode.dev/102-eu-compliance-questions-we-had-never-seen-our-law-index-found-the-article-first-76-times-a-web-search-api-34</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/102-eu-compliance-questions-we-had-never-seen-our-law-index-found-the-article-first-76-times-a-web-search-api-34</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 09:32:43 GMT</pubDate><content:encoded><![CDATA[<p>Yesterday we published a small test: 20 EU compliance questions, our EU law search against Exa's web search. Fair
criticism of a 20-question test is that we might have tuned our ranking on exactly those 20. We did. So today we wrote
<strong>102 new questions</strong> and ran them before touching the ranking.</p>
<h2>The test</h2>
<ul>
<li>102 questions across 41 EU acts: GDPR, the AI Act, DSA, DMA, NIS2, DORA, MiCA, the VAT Directive, PSD2, the
anti-money-laundering rules, consumer, product-safety and sustainability law.</li>
<li>Each question names the article a correct answer must cite ("when must a company appoint a data protection officer"
→ GDPR Article 37). Every expected article was checked against the law's own text before either search ran.</li>
<li><strong>Ours</strong> counts only when the result <em>is</em> that article. <strong>Exa</strong> (search type <code>auto</code>, 5 results) counts when the title,
URL or first 1,500 characters name the article number and the act, a deliberately lenient rule.</li>
</ul>
<h2>Results</h2>
<table>
<thead>
<tr>
<th></th>
<th>Right article first</th>
<th>Right article in top 5</th>
</tr>
</thead>
<tbody><tr>
<td>Our EU law index</td>
<td><strong>76 / 102</strong></td>
<td><strong>96 / 102</strong></td>
</tr>
<tr>
<td>Exa search (auto)</td>
<td>34 / 102</td>
<td>75 / 102</td>
</tr>
</tbody></table>
<p>On the 20 questions we did tune on, the picture is the same: ours 10 and 19, Exa 4 and 13.</p>
<h2>Why the gap</h2>
<p>A web search returns pages <em>about</em> the law: regulators' guidance, law-firm explainers, glossaries. Those are useful,
but an agent that has to cite a provision needs the provision. Our index holds 47 EU acts article by article, in their
latest consolidated text from the EU's own publications office, hosted in the EU.</p>
<h2>Where we lost</h2>
<p>Six questions had no right article in our top 5. Three were VAT questions: the VAT Directive's articles carry no
headings in the official text, which our ranking leans on. "Health data" pulled up the European Health Data Space
instead of GDPR Article 9. We will fix these against a fresh set of questions, not these 102.</p>
<h2>Limits, plainly</h2>
<ul>
<li>We wrote the questions. They are checked against the law, not against either search, and they are public.</li>
<li>The questions do not say "EU"; some of Exa's answers were UK or US pages, which a question naming the EU might avoid.</li>
<li>English only so far.</li>
</ul>
<h2>Try it</h2>
<p>The <a href="https://github.com/Nutshell2000/agent-data-tools/blob/claude/law-eval-100/scripts/law-index/eval-questions.json">122 questions with their expected articles</a>
and both scoring scripts (<a href="https://github.com/Nutshell2000/agent-data-tools/blob/claude/law-eval-100/scripts/law-index/eval-ours.mjs">ours</a>,
<a href="https://github.com/Nutshell2000/agent-data-tools/blob/claude/law-eval-100/scripts/law-index/bench-exa.mjs">Exa's</a>) are in our
public repository, so anyone can re-run them. If you already use Exa's SDK,
point it at our base URL: the same <code>search</code>, <code>contents</code> and <code>answer</code> calls work, including structured answers, and
EU-law questions are answered from the index.</p>
<pre><code class="language-python">from exa_py import Exa
exa = Exa(api_key="YOUR_KEY", base_url="https://tools.funwords.eu/v1")
exa.search("when must a company appoint a data protection officer", category="law", num_results=5)
</code></pre>
<p>Every result carries the act, the article, its text and the EUR-Lex link. Send us your hardest compliance questions and
we will add them to the next run.</p>
]]></content:encoded></item><item><title><![CDATA[Core Web Vitals for 500 URLs in one run, with the fixes ranked by time saved (no API key, $3 per 1,000)]]></title><description><![CDATA[pagespeed.web.dev is great for one page. For a client's top 200 pages, or every product page before a release, you end up pasting URLs one at a time and…]]></description><link>https://spellzcode.hashnode.dev/core-web-vitals-for-500-urls-in-one-run-with-the-fixes-ranked-by-time-saved-no-api-key-3-per-1-000</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/core-web-vitals-for-500-urls-in-one-run-with-the-fixes-ranked-by-time-saved-no-api-key-3-per-1-000</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 08:52:58 GMT</pubDate><content:encoded><![CDATA[<p>pagespeed.web.dev is great for one page. For a client's top 200 pages, or every product page before a release, you end up pasting URLs one at a time and copying scores into a sheet.</p>
<p>This guide runs Google's own PageSpeed Insights engine on a whole list of URLs and returns one row per page. Each row has the four Lighthouse scores, the <strong>real-user Core Web Vitals</strong> (the same pass/fail verdict Search Console shows), and the top fixes <strong>ranked by milliseconds saved</strong>.</p>
<p>No Google account, API key or quota to manage.</p>
<h2>Input</h2>
<p>Open <a href="https://apify.com/spellzcode/pagespeed-insights-bulk-audit">PageSpeed Insights Bulk Audit</a> and paste your URLs:</p>
<pre><code class="language-json">{
  "urls": [
    "https://www.example.com/",
    "https://www.example.com/pricing",
    "https://www.example.com/blog/"
  ],
  "strategy": "mobile"
}
</code></pre>
<p>Mobile is what Google ranks on. Choose <code>both</code> to get a mobile and a desktop row for every page.</p>
<h2>Output</h2>
<p>One row per page and device. From a real run on cnn.com (mobile, 15 Nov 2026):</p>
<pre><code class="language-json">{
  "url": "https://www.cnn.com/",
  "strategy": "mobile",
  "status": "ok",
  "performanceScore": 19,
  "seoScore": 92,
  "accessibilityScore": 93,
  "bestPracticesScore": 54,
  "passesCoreWebVitals": true,
  "coreWebVitalsPage": {
    "overall": "FAST",
    "lcpMs": {
      "p75": 1485,
      "rating": "FAST"
    },
    "inpMs": {
      "p75": 160,
      "rating": "FAST"
    },
    "cls": {
      "p75": 0.04,
      "rating": "FAST"
    },
    "fcpMs": {
      "p75": 1051,
      "rating": "FAST"
    },
    "ttfbMs": {
      "p75": 256,
      "rating": "FAST"
    }
  },
  "lab": {
    "lcpMs": 6903,
    "fcpMs": 6903,
    "tbtMs": 2084,
    "speedIndexMs": 17806,
    "cls": 0.197,
    "ttfbMs": 110
  },
  "opportunities": [
    {
      "id": "unused-javascript",
      "title": "Reduce unused JavaScript",
      "savingsMs": 1360,
      "savingsBytes": 2487351
    }
  ],
  "failedSeoChecks": [
    "robots.txt is not valid"
  ]
}
</code></pre>
<p>Note the split: a <strong>performance score of 19</strong> in the lab, while real Chrome users get a fast page and it <strong>passes Core Web Vitals</strong>. The lab simulates a slow phone on a throttled network; the field data is what visitors actually experienced. That's why the bulk report gives you both.</p>
<p>What to look at first:</p>
<ul>
<li><strong><code>passesCoreWebVitals</code></strong>: Google's own pass/fail from real Chrome users over the last 28 days. It's the number that affects ranking; the lab score doesn't.</li>
<li><strong><code>coreWebVitalsPage</code> vs <code>coreWebVitalsOrigin</code></strong>: small pages often have no field data of their own (<code>null</code>), so the origin's numbers are the fallback Google uses too.</li>
<li><strong><code>opportunities</code></strong>: already sorted by time saved. Fixing the first one or two usually moves the score more than everything else combined.</li>
</ul>
<h2>Sorting a big list</h2>
<p>Export as CSV and sort by <code>performanceScore</code>, or filter <code>passesCoreWebVitals = false</code>. Then group the <code>opportunities[0].title</code> column. On most sites, a handful of fixes (one script, one hero image, one font) cover most failing pages.</p>
<h2>Before and after a release</h2>
<p>Save the list as a task and run it on a schedule (Apify → Schedules). Each run keeps its own dataset, so you can compare scores per URL from one deploy to the next.</p>
<h2>Run it from code</h2>
<pre><code class="language-bash">curl -X POST "https://api.apify.com/v2/acts/spellzcode~pagespeed-insights-bulk-audit/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://www.example.com/"],"strategy":"mobile"}'
</code></pre>
<h2>Cost</h2>
<p>$0.003 per audit, so $3 per 1,000. Pages Google can't load are reported with Google's message and cost nothing. Apify's free monthly credit covers about 1,700 audits.</p>
<h2>Limits</h2>
<ul>
<li>Field data exists only for pages and origins with enough Chrome traffic. A <code>null</code> there is Google's answer, not an error.</li>
<li>Lab scores move a few points between runs, exactly as on pagespeed.web.dev.</li>
<li>Only public pages: anything behind a login comes back <code>failed</code>, free.</li>
</ul>
<p>Related: <a href="https://apify.com/spellzcode/website-seo-audit">Website SEO Audit</a> checks titles, descriptions, headings and canonical tags on every page of a site, with a 0 to 100 score per page.</p>
]]></content:encoded></item><item><title><![CDATA[Podcast episodes to text and SRT subtitles: from an Apple link to a transcript in 60 lines]]></title><description><![CDATA[You want the transcript of a podcast episode, as plain text and as subtitles. Maybe you're writing show notes, building a searchable archive, or feeding…]]></description><link>https://spellzcode.hashnode.dev/podcast-episodes-to-text-and-srt-subtitles-from-an-apple-link-to-a-transcript-in-60-lines</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/podcast-episodes-to-text-and-srt-subtitles-from-an-apple-link-to-a-transcript-in-60-lines</guid><category><![CDATA[podcast]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[whisper]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 08:01:14 GMT</pubDate><content:encoded><![CDATA[<p>You want the transcript of a podcast episode, as plain text and as subtitles. Maybe you're writing show notes, building
a searchable archive, or feeding episodes to an LLM. Most guides start from an MP3 file you already have. In practice
you start from an Apple Podcasts link or a show name, and the episode is an hour long.</p>
<p>This post goes through the whole route, with code that runs on Node 20 and has no dependencies besides <code>ffmpeg</code>:</p>
<ol>
<li>Apple Podcasts link to RSS feed</li>
<li>RSS feed to episode audio URLs</li>
<li>Long audio to 5-minute parts</li>
<li>Parts to Whisper, then timestamps joined back into SRT</li>
<li>The two Whisper quirks that will bite you on real podcasts</li>
</ol>
<h2>1. From an Apple Podcasts link to the RSS feed</h2>
<p>Almost every podcast is an RSS feed underneath. Apple hides it, but its public lookup API returns it. The show id is
the number after <code>/id</code> in the link:</p>
<pre><code class="language-js">// https://podcasts.apple.com/us/podcast/the-daily/id1200361736  -&gt;  1200361736
const id = /\/id(\d+)/.exec(new URL(link).pathname)?.[1];
const res = await fetch(`https://itunes.apple.com/lookup?id=${id}&amp;entity=podcast`);
const feedUrl = (await res.json()).results[0].feedUrl;
// https://feeds.simplecast.com/54nAGcIl
</code></pre>
<p>No key, no account. Spotify-exclusive shows are the only common case without a feed. Most shows you can play on
Spotify also publish RSS, so look them up on Apple.</p>
<h2>2. Episodes and their audio files</h2>
<p>Each <code>&lt;item&gt;</code> in the feed has an <code>&lt;enclosure url="..."&gt;</code> pointing at the audio file. A regex parser is enough for
podcast feeds. They are regular, and you avoid an XML dependency:</p>
<pre><code class="language-js">const xml = await (await fetch(feedUrl)).text();
const items = xml.match(/&lt;item[\s&gt;][\s\S]*?&lt;\/item&gt;/gi) ?? [];
const episodes = items.map((it) =&gt; ({
  title: /&lt;title&gt;(?:&lt;!\[CDATA\[)?([\s\S]*?)(?:\]\]&gt;)?&lt;\/title&gt;/i.exec(it)?.[1].trim(),
  date: /&lt;pubDate&gt;([^&lt;]+)&lt;\/pubDate&gt;/i.exec(it)?.[1],
  audio: /&lt;enclosure\s[^&gt;]*?url\s*=\s*["']([^"']+)["']/i.exec(it)?.[1]?.replace(/&amp;amp;/g, '&amp;'),
})).filter((e) =&gt; e.audio);
</code></pre>
<p>Two things to know:</p>
<ul>
<li>Enclosure URLs are usually <strong>tracking redirects</strong> (podtrac, chartable and so on). <code>fetch</code> follows them; just don't
try to guess the file type from the URL.</li>
<li>Feeds are not always sorted newest first. Sort by <code>pubDate</code> yourself.</li>
</ul>
<h2>3. Split long audio into parts</h2>
<p>Hosted Whisper endpoints cap the upload size (25 MB at OpenAI), and one long request is fragile anyway. Convert to
16 kHz mono MP3 and cut it into 5-minute parts in one ffmpeg call:</p>
<pre><code class="language-bash">ffmpeg -i episode.mp3 -vn -ac 1 -ar 16000 -c:a libmp3lame -b:a 32k \
  -f segment -segment_time 300 -reset_timestamps 1 part%04d.mp3
</code></pre>
<p>At 32 kbps a 5-minute part is about 1.2 MB, and Whisper doesn't need more for speech. Video files work the same way:
<code>-vn</code> drops the picture.</p>
<p><strong>Measure each part's real length</strong> with <code>ffprobe</code> instead of assuming 300 seconds. The segment muxer cuts on frame
boundaries, and over an hour those small differences shift every subtitle.</p>
<pre><code class="language-js">const offsets = [];
let t = 0;
for (const part of parts) { offsets.push(t); t += await durationOf(part); } // ffprobe -show_entries format=duration
</code></pre>
<h2>4. Transcribe each part and join the timestamps</h2>
<p>Send the parts to any Whisper endpoint (OpenAI, Groq, Cloudflare Workers AI, or a local whisper.cpp). Ask for
segment timestamps, then shift each part's segments by that part's offset:</p>
<pre><code class="language-js">const segments = [];
results.forEach((r, i) =&gt; {
  for (const s of r.segments) segments.push({ start: offsets[i] + s.start, end: offsets[i] + s.end, text: s.text.trim() });
});
</code></pre>
<p>SRT is just numbered cues with <code>HH:MM:SS,mmm</code> times:</p>
<pre><code class="language-js">const stamp = (sec) =&gt; new Date(sec * 1000).toISOString().slice(11, 23).replace('.', ',');
const srt = segments.map((s, i) =&gt; `${i + 1}\n${stamp(s.start)} --&gt; ${stamp(s.end)}\n${s.text}\n`).join('\n');
</code></pre>
<p>(The <code>toISOString</code> trick only works under 24 hours, which covers every podcast.) For WebVTT, put <code>WEBVTT\n\n</code> on
top and use <code>.</code> instead of <code>,</code>.</p>
<h2>5. Two Whisper quirks you will meet on real podcasts</h2>
<p>We ran this on a couple of hours of real episodes and speeches. Two problems showed up that tidy demo files never
trigger:</p>
<p><strong>Repeated phrases over applause or music.</strong> In a music bed or applause, Whisper often outputs "Thank you." six
times in a row. Drop a short segment that repeats the previous one within a few seconds:</p>
<pre><code class="language-js">if (prev &amp;&amp; text.length &lt;= 40 &amp;&amp; prev.text.toLowerCase() === text.toLowerCase() &amp;&amp; start - prev.end &lt; 8) continue;
</code></pre>
<p><strong>Invented words in very short segments.</strong> With voice-activity filtering on, which otherwise gives nicer, shorter
subtitle lines, Whisper sometimes produces gibberish segments only 0.02 to 0.1 seconds long. People speak about 15
characters a second, so anything over 60 is not speech:</p>
<pre><code class="language-js">if (end &gt; start &amp;&amp; text.length / (end - start) &gt; 60) continue;
</code></pre>
<p>In our tests, these two filters removed the bad lines we found and kept the real speech around them.</p>
<h2>The no-code version</h2>
<p>If you'd rather not run ffmpeg and a Whisper key yourself, we packaged exactly this pipeline as two Apify actors:</p>
<ul>
<li><a href="https://apify.com/spellzcode/podcast-transcriber">Podcast Transcriber</a>: RSS feed or Apple Podcasts link in,
latest episodes (or a date or title filter) out as text, SRT and VTT.</li>
<li><a href="https://apify.com/spellzcode/audio-video-transcriber">Audio &amp; Video Transcriber</a>: any audio or video file link,
Google Drive or Dropbox share links included.</li>
</ul>
<p>Both cost $0.008 per audio minute, subtitles included. Apify's free monthly credit covers about 10 hours. Disclosure:
we (SpellzCode) make them.</p>
<p>Either way, the pipeline above is all there is to it: feed lookup, enclosure, ffmpeg segments, Whisper, offsets, and
two filters for the noise.</p>
]]></content:encoded></item><item><title><![CDATA[Transcribing a two-hour recording in the browser: split it into MP3 parts, then stitch the SRT back together]]></title><description><![CDATA[Most speech-to-text APIs cap a request at about 25 MB or an hour of audio. Real recordings blow past that: a lecture saved as a 900 MB MP4, a three-hour…]]></description><link>https://spellzcode.hashnode.dev/transcribing-a-two-hour-recording-in-the-browser-split-it-into-mp3-parts-then-stitch-the-srt-back-together</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/transcribing-a-two-hour-recording-in-the-browser-split-it-into-mp3-parts-then-stitch-the-srt-back-together</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 07:53:00 GMT</pubDate><content:encoded><![CDATA[<p>Most speech-to-text APIs cap a request at about 25 MB or an hour of audio. Real recordings blow past that: a lecture saved as a 900 MB MP4, a three-hour workshop, a podcast exported as WAV. The usual fix is "ask the user to cut it up first", which nobody does.</p>
<p>You can do the cutting in the browser instead. The visitor picks one file, and the page:</p>
<ol>
<li>decodes whatever format it is (MP4, MOV, M4A, OGG, WAV…) into raw samples,</li>
<li>downmixes to 16 kHz mono, which is all a speech model needs,</li>
<li>encodes parts of under an hour as small MP3s,</li>
<li>sends the parts one after another,</li>
<li>shifts each part's timestamps and joins everything into one transcript and one SRT file.</li>
</ol>
<p>Here is how each step works, with the code we use in production.</p>
<h2>1. Decode any format at 16 kHz</h2>
<p><code>decodeAudioData</code> handles every container the browser can play, video included. If you create the <code>AudioContext</code> at 16,000 Hz, the browser resamples for you:</p>
<pre><code class="language-js">async function decode(file) {
  const buf = await file.arrayBuffer();
  const ctx = new AudioContext({ sampleRate: 16000 });
  try {
    const audio = await ctx.decodeAudioData(buf);
    const n = audio.length, mono = new Float32Array(n), ch = audio.numberOfChannels;
    for (let c = 0; c &lt; ch; c++) {
      const d = audio.getChannelData(c);
      for (let i = 0; i &lt; n; i++) mono[i] += d[i] / ch;
    }
    return mono; // 16,000 floats per second
  } finally { ctx.close(); }
}
</code></pre>
<p>An hour of 16 kHz mono is 57.6 million floats, about 230 MB in memory. That's fine on a laptop. On phones, keep recordings under a couple of hours.</p>
<h2>2. Encode MP3 parts in a Web Worker</h2>
<p>A 32 kbps mono MP3 is about 14 MB per hour: small enough for any API limit and plenty for speech. <a href="https://github.com/zhuker/lamejs">lamejs</a> encodes in pure JavaScript. Run it in a worker so the page stays responsive:</p>
<pre><code class="language-js">// mp3-worker.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/lamejs/1.2.1/lame.min.js");
const RATE = 16000, KBPS = 32, BLOCK = 1152;

self.onmessage = ({ data: { pcm, partSeconds } }) =&gt; {
  const perPart = partSeconds * RATE;
  const parts = Math.ceil(pcm.length / perPart);
  for (let p = 0; p &lt; parts; p++) {
    const enc = new lamejs.Mp3Encoder(1, RATE, KBPS);
    const from = p * perPart, to = Math.min(pcm.length, from + perPart);
    const chunks = [], block = new Int16Array(BLOCK);
    for (let i = from; i &lt; to; i += BLOCK) {
      const n = Math.min(BLOCK, to - i);
      for (let j = 0; j &lt; n; j++) {
        const s = Math.max(-1, Math.min(1, pcm[i + j]));
        block[j] = s &lt; 0 ? s * 0x8000 : s * 0x7fff;
      }
      const out = enc.encodeBuffer(n === BLOCK ? block : block.subarray(0, n));
      if (out.length) chunks.push(new Uint8Array(out));
    }
    chunks.push(new Uint8Array(enc.flush()));
    self.postMessage({ index: p, offset: from / RATE, blob: new Blob(chunks, { type: "audio/mpeg" }) });
  }
  self.postMessage({ done: true });
};
</code></pre>
<p>Two details matter:</p>
<ul>
<li><strong>A fresh encoder per part.</strong> Each part becomes a complete, valid MP3, not a slice of one stream.</li>
<li><strong>Transfer the buffer</strong> (<code>worker.postMessage({ pcm, partSeconds }, [pcm.buffer])</code>) instead of copying 230 MB.</li>
</ul>
<h2>3. Send the parts and shift the timestamps</h2>
<p>Each part comes back with segments timed from zero. Add the part's offset and you have one timeline:</p>
<pre><code class="language-js">const all = [];
for (const part of parts) {
  const res = await fetch(API + "/transcribe/long?timestamps=true", {
    method: "POST",
    headers: { authorization: "Bearer " + key, "content-type": "application/octet-stream" },
    body: part.blob,
  });
  const body = await res.json();
  for (const s of body.segments) all.push({ start: s.start + part.offset, end: s.end + part.offset, text: s.text.trim() });
}
</code></pre>
<h2>4. Write SRT and VTT</h2>
<pre><code class="language-js">function stamp(t, sep) {
  const ms = Math.round(t * 1000), p = (n, w) =&gt; String(n).padStart(w, "0");
  return p(Math.floor(ms / 3600000), 2) + ":" + p(Math.floor(ms / 60000) % 60, 2) + ":" +
         p(Math.floor(ms / 1000) % 60, 2) + sep + p(ms % 1000, 3);
}
const srt = all.map((s, i) =&gt; `${i + 1}\n${stamp(s.start, ",")} --&gt; ${stamp(s.end, ",")}\n${s.text}\n`).join("\n");
const vtt = "WEBVTT\n\n" + all.map((s) =&gt; `${stamp(s.start, ".")} --&gt; ${stamp(s.end, ".")}\n${s.text}\n`).join("\n");
</code></pre>
<p>In our test (a three-minute recording forced into four one-minute parts), all 46 cues came back in order and the timings kept rising across every join.</p>
<h2>The one weak spot: the cut</h2>
<p>A hard cut can land mid-word, and the model then guesses at the fragment on each side. With 55-minute parts that happens about once an hour of audio, and only for a word or two. If it matters to you, cut at the quietest 0.5 s within the last 30 seconds of each part instead of at a fixed sample. The RMS of short windows is enough to find it.</p>
<h2>Where this runs</h2>
<p>This is the "Pro" mode of <a href="https://glyphcall-voice.pages.dev/transcribe">Glyphcall Transcribe</a>, which we (SpellzCode) make. The free mode runs Whisper entirely in the browser with Transformers.js, so nothing is uploaded. Pro sends the MP3 parts to our servers for people on phones, slow laptops or long recordings ($1 for 20 hours, or $9 a month).</p>
<p>The splitting code above works with any speech-to-text API that takes an audio file. Swap the <code>fetch</code> for yours.</p>
]]></content:encoded></item><item><title><![CDATA[Get exact TikTok views, likes and saves for a list of video links (plus the transcript), no login, $1 per 1,000]]></title><description><![CDATA[If you run influencer campaigns, someone has to report how each creator video did. Usually that means asking creators for screenshots, or opening 40 videos…]]></description><link>https://spellzcode.hashnode.dev/get-exact-tiktok-views-likes-and-saves-for-a-list-of-video-links-plus-the-transcript-no-login-1-per-1-000</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/get-exact-tiktok-views-likes-and-saves-for-a-list-of-video-links-plus-the-transcript-no-login-1-per-1-000</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 07:30:27 GMT</pubDate><content:encoded><![CDATA[<p>If you run influencer campaigns, someone has to report how each creator video did. Usually that means asking creators for screenshots, or opening 40 videos and copying "1.7M" into a sheet. "1.7M" isn't even the real number.</p>
<p>This guide turns a list of TikTok video links into rows with the <strong>exact</strong> counts: views, likes, comments, shares and saves. It also adds engagement rate, hashtags, the sound used, the author's follower count and, for talking videos, the transcript.</p>
<p>It reads public video pages only: no login, no cookies, no browser extension.</p>
<h2>Input</h2>
<p>Open <a href="https://apify.com/spellzcode/tiktok-video-scraper">TikTok Video Scraper</a> and paste your links. Full links, <code>vm.tiktok.com</code> short links and bare video IDs all work:</p>
<pre><code class="language-json">{
  "videos": [
    "https://www.tiktok.com/@nasa/video/7676868860749827342",
    "https://www.tiktok.com/@duolingo/video/7460972535832644907",
    "https://vm.tiktok.com/ZMxxxxxxx/"
  ],
  "includeTranscript": true
}
</code></pre>
<h2>Output</h2>
<p>One row per video. From a real run:</p>
<pre><code class="language-json">{
  "status": "ok",
  "url": "https://www.tiktok.com/@nasa/video/7676868860749827342",
  "description": "The Moon understood the assignment 🌕",
  "createdAt": "2026-08-22T14:52:29.000Z",
  "views": 1700000,
  "likes": 261200,
  "comments": 2122,
  "shares": 11800,
  "saves": 20430,
  "engagementRatePercent": 17.39,
  "viewsPerFollower": 0.773,
  "authorUsername": "nasa",
  "authorFollowers": 2200000,
  "musicTitle": "original sound - NASA",
  "locationCreated": "US",
  "categories": ["Science", "Education"],
  "suggestedSearches": ["moon", "artemis", "moon footage"]
}
</code></pre>
<p><code>engagementRatePercent</code> is (likes + comments + shares + saves) / views. <code>viewsPerFollower</code> shows how far a video travelled beyond the creator's own audience. Above 1 means the For You page picked it up.</p>
<p>When the video has speech and TikTok has captions for it, you also get <code>transcript</code>:</p>
<blockquote>
<p>"Are you doing research in HR or do you want to get a structured list of job listings without endlessly scrolling through? …"</p>
</blockquote>
<h2>Run it from code</h2>
<pre><code class="language-bash">curl -X POST "https://api.apify.com/v2/acts/spellzcode~tiktok-video-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videos":["https://www.tiktok.com/@nasa/video/7676868860749827342"]}'
</code></pre>
<p>Or in Python:</p>
<pre><code class="language-python">from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("spellzcode/tiktok-video-scraper").call(run_input={
    "videos": ["https://www.tiktok.com/@nasa/video/7676868860749827342"],
})
for v in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(v["url"], v.get("views"), v.get("engagementRatePercent"))
</code></pre>
<h2>Daily tracking</h2>
<p>Save your campaign links as a task and give it a daily schedule (Apify → Schedules). Each run adds a dated snapshot, so you can chart how views grow over the first week.</p>
<h2>Cost</h2>
<p>$0.001 per video returned, so $1 per 1,000. Deleted, private and region-locked videos cost nothing; they come back with <code>status: "not_found"</code> and a reason. Apify's free monthly credit covers about 5,000 videos.</p>
<h2>Limits</h2>
<ul>
<li>Link-based: it reads the videos you give it. It doesn't search hashtags or list a profile's videos.</li>
<li>Transcripts exist only when TikTok has captions, which is mostly videos with speech.</li>
<li>It reads one page at a time without proxies. If TikTok refuses a page, it retries once and then reports it as free instead of guessing.</li>
</ul>
<p>Related: <a href="https://apify.com/spellzcode/tiktok-profile-data">TikTok Profile Scraper</a> gives follower, like and video counts by username, for vetting creators before a campaign.</p>
]]></content:encoded></item><item><title><![CDATA[Whisper transcription and SRT subtitles with the OpenAI SDK, without an OpenAI account (one-line change)]]></title><description><![CDATA[The OpenAI SDK is a good HTTP client for audio. client.audio.transcriptions.create() handles multipart uploads, response_format="srt" gives you subtitles…]]></description><link>https://spellzcode.hashnode.dev/whisper-transcription-and-srt-subtitles-with-the-openai-sdk-without-an-openai-account-one-line-change</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/whisper-transcription-and-srt-subtitles-with-the-openai-sdk-without-an-openai-account-one-line-change</guid><category><![CDATA[openai]]></category><category><![CDATA[whisper]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sun, 15 Nov 2026 07:14:17 GMT</pubDate><content:encoded><![CDATA[<p>The OpenAI SDK is a good HTTP client for audio. <code>client.audio.transcriptions.create()</code> handles multipart uploads,
<code>response_format="srt"</code> gives you subtitles, and <code>client.audio.speech.create()</code> streams MP3. Plenty of tools,
scripts and agents are already written against it.</p>
<p>The SDK doesn't care whose server it talks to. Point <code>base_url</code> at any OpenAI-compatible endpoint and the same code
runs. That matters when:</p>
<ul>
<li>the person running your script has no OpenAI account or card on file;</li>
<li>you want an hour of audio to cost less than OpenAI's $0.36 (whisper-1 at $0.006 a minute);</li>
<li>you are an agent that can pay per request but cannot sign up for anything.</li>
</ul>
<h2>The one-line change</h2>
<pre><code class="language-python">from openai import OpenAI

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://agent-data-tools.revmesh2074.workers.dev/v1",  # &lt;- the only change
)

with open("meeting.mp3", "rb") as f:
    srt = client.audio.transcriptions.create(model="whisper-1", file=f, response_format="srt")
open("meeting.srt", "w").write(srt)

client.audio.speech.create(model="tts-1", voice="alloy", input="Your order has shipped.").write_to_file("hi.mp3")
</code></pre>
<p>The Node SDK takes <code>baseURL</code> in the same way. <code>json</code>, <code>text</code>, <code>srt</code>, <code>vtt</code> and <code>verbose_json</code> all come back in
OpenAI's format, and OpenAI voice names map to similar voices. We ran each of these calls with the stock
<code>openai</code> packages (Python and Node) before writing this.</p>
<h2>What is behind it</h2>
<p>Disclosure: the endpoint is ours (SpellzCode). It runs Whisper large-v3-turbo for transcription and Deepgram Aura
voices for speech. The trade-offs, honestly:</p>
<table>
<thead>
<tr>
<th></th>
<th>OpenAI</th>
<th>This endpoint</th>
</tr>
</thead>
<tbody><tr>
<td>Account to start</td>
<td>Yes, plus a card</td>
<td>No: a $1 card top-up gives a key, or an agent pays per call in USDC (x402)</td>
</tr>
<tr>
<td>One hour of audio</td>
<td>$0.36 (whisper-1), $0.18 (gpt-4o-mini-transcribe)</td>
<td>$0.05 per file up to 60 min (<code>/transcribe/long</code>)</td>
</tr>
<tr>
<td>Short clip</td>
<td>per minute</td>
<td>$0.01 per file up to 5 MB</td>
</tr>
<tr>
<td>Subtitles</td>
<td><code>srt</code> / <code>vtt</code></td>
<td><code>srt</code> / <code>vtt</code></td>
</tr>
<tr>
<td>Speech languages</td>
<td>many</td>
<td>English and Spanish</td>
</tr>
<tr>
<td>Failed calls</td>
<td></td>
<td>never charged</td>
</tr>
</tbody></table>
<p>If you need many speech languages or a specific OpenAI model such as gpt-4o-transcribe, stay on OpenAI. If you mostly
transcribe and want no account and a lower bill, this is a one-line switch.</p>
<h2>Long recordings</h2>
<p>The OpenAI endpoint caps uploads at 25 MB. For meetings and podcasts there is a separate call that takes up to 60
minutes of MP3 or WAV, splits it into parts and joins the timestamps:</p>
<pre><code class="language-bash">curl -s -G "https://agent-data-tools.revmesh2074.workers.dev/transcribe/long" \
  -H "Authorization: Bearer $API_KEY" \
  --data-urlencode "url=https://example.com/episode.mp3" \
  --data-urlencode "subtitles=srt" | jq -r .subtitles &gt; episode.srt
</code></pre>
<p>A 9.7-minute speech came back in 3 parts with continuous SRT timestamps.</p>
<h2>Code ElevenLabs users can keep</h2>
<p>The same endpoint also answers <code>POST /v1/speech-to-text</code> and <code>POST /v1/text-to-speech/{voice_id}</code> in ElevenLabs'
shape, with the same <code>xi-api-key</code> header. Only the host changes.</p>
<p>All the examples, tested, MIT licensed:
<a href="https://github.com/Nutshell2000/voice-api-no-account-examples">https://github.com/Nutshell2000/voice-api-no-account-examples</a></p>
]]></content:encoded></item><item><title><![CDATA[Transcribe audio to SRT subtitles in the browser with Whisper (no upload, no server)]]></title><description><![CDATA[You can run Whisper inside a web page today. The audio file never leaves the visitor's computer: the browser downloads the speech model once, caches it…]]></description><link>https://spellzcode.hashnode.dev/transcribe-audio-to-srt-subtitles-in-the-browser-with-whisper-no-upload-no-server</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/transcribe-audio-to-srt-subtitles-in-the-browser-with-whisper-no-upload-no-server</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 16:05:07 GMT</pubDate><content:encoded><![CDATA[<p>You can run Whisper inside a web page today. The audio file never leaves the visitor's computer: the browser downloads the speech model once, caches it, and does the listening itself. No server, no API key, no per-minute bill.</p>
<p>This post shows how to build it with Transformers.js: a Web Worker, WebGPU with a WASM fallback, long files in blocks, and SRT/VTT output. It also covers the three things that tripped us up. A working version is at the end if you want to try it before reading the code.</p>
<h2>1. Decode the file to 16 kHz mono</h2>
<p>Whisper wants 16,000 samples per second, one channel. The Web Audio API resamples for you if you create the context at that rate:</p>
<pre><code class="language-js">async function decode(file) {
  const ctx = new AudioContext({ sampleRate: 16000 });
  try {
    const audio = await ctx.decodeAudioData(await file.arrayBuffer());
    const n = audio.length, mono = new Float32Array(n), ch = audio.numberOfChannels;
    for (let c = 0; c &lt; ch; c++) {
      const d = audio.getChannelData(c);
      for (let i = 0; i &lt; n; i++) mono[i] += d[i] / ch;
    }
    return mono;
  } finally { ctx.close(); }
}
</code></pre>
<p>This handles MP3, M4A, WAV, OGG, FLAC, and also the audio track of MP4 and WebM video, because the browser's own decoders do the work.</p>
<h2>2. Load the model in a Web Worker</h2>
<p>Recognition blocks the thread for seconds at a time, so it goes in a module worker. Try WebGPU first and fall back to WASM:</p>
<pre><code class="language-js">// stt-worker.js
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.5.1";

async function load(id) {
  if (navigator.gpu &amp;&amp; await navigator.gpu.requestAdapter().catch(() =&gt; null)) {
    try {
      return await pipeline("automatic-speech-recognition", id, {
        device: "webgpu",
        dtype: { encoder_model: "fp32", decoder_model_merged: "q4" },
      });
    } catch { /* fall through to the CPU */ }
  }
  return pipeline("automatic-speech-recognition", id, { device: "wasm", dtype: "q8" });
}
</code></pre>
<p><code>onnx-community/whisper-tiny</code> is about 40 MB, <code>whisper-base</code> about 80 MB and <code>whisper-small</code> about 250 MB. Base is a good default for clear speech. Small is noticeably better with accents, noise and languages other than English.</p>
<p>Pass <code>progress_callback</code> to <code>pipeline()</code> if you want a download bar. It reports <code>loaded</code> and <code>total</code> per file.</p>
<h2>3. Work through long files in blocks</h2>
<p>Handing an hour of audio to the pipeline in one call works, but the page shows nothing until the very end. Feed it 90-second blocks instead, shift each block's timestamps by its offset, and post partial results as you go:</p>
<pre><code class="language-js">const RATE = 16000, BLOCK = 90 * RATE;
const opts = { chunk_length_s: 30, stride_length_s: 5, return_timestamps: true,
               task: "transcribe", language: "swedish" };
const segments = [];
for (let start = 0; start &lt; pcm.length; start += BLOCK) {
  const block = pcm.subarray(start, Math.min(pcm.length, start + BLOCK));
  const offset = start / RATE;
  const out = await asr(block, opts);
  for (const c of out.chunks || []) {
    const s = c.timestamp?.[0] ?? 0;
    let e = c.timestamp?.[1];
    if (e == null || e &lt; s) e = Math.min(block.length / RATE, s + 5); // last chunk can lack an end
    if (c.text.trim()) segments.push({ start: offset + s, end: offset + e, text: c.text.trim() });
  }
  postMessage({ type: "progress", done: offset + block.length / RATE, segments });
}
</code></pre>
<h2>4. Write SRT and VTT</h2>
<p>The two formats differ only in the header, the numbering and the millisecond separator:</p>
<pre><code class="language-js">function stamp(t, sep) {
  const ms = Math.max(0, Math.round(t * 1000)), p = (n, w) =&gt; String(n).padStart(w, "0");
  return `${p(Math.floor(ms / 3600000), 2)}:${p(Math.floor(ms / 60000) % 60, 2)}:` +
         `${p(Math.floor(ms / 1000) % 60, 2)}${sep}${p(ms % 1000, 3)}`;
}
const srt = (segs) =&gt; segs.map((s, i) =&gt;
  `${i + 1}\n${stamp(s.start, ",")} --&gt; ${stamp(s.end, ",")}\n${s.text}\n`).join("\n");
const vtt = (segs) =&gt; "WEBVTT\n\n" + segs.map((s) =&gt;
  `${stamp(s.start, ".")} --&gt; ${stamp(s.end, ".")}\n${s.text}\n`).join("\n");
</code></pre>
<p>Both load straight into YouTube Studio and most video editors.</p>
<h2>Three things that tripped us up</h2>
<p><strong>1. Always pass a language.</strong> With Transformers.js 3.5.1 and no <code>language</code> option, Whisper assumed English and <em>translated</em> a Swedish recording into English instead of transcribing it. It did not detect the language. Preselect a language from <code>navigator.language</code> and let the user change it.</p>
<p><strong>2. The model host can refuse your page's origin.</strong> In our tests on 14 Nov, Hugging Face's model files answered 404 to browser requests whose <code>Referer</code> was a <code>*.workers.dev</code> page. The same requests from <code>*.pages.dev</code> and from real domains got 200. If the model "is not found" only in production, check where the page is hosted before you check the model ID.</p>
<p><strong>3. The first run is the slow one.</strong> Downloading the model takes most of the first run's time. Say so in the UI ("fetching the listening model, first time only"), because people assume it has hung. Later runs load from the browser cache in a second or two.</p>
<h2>When the browser is the wrong place</h2>
<p>In-browser transcription is great for privacy and costs nothing to run, but it depends on the visitor's hardware, and it does not fit batch jobs or a backend pipeline. For those you want a server-side call to a bigger model.</p>
<h2>Try it</h2>
<p>Disclosure: we (SpellzCode) make both of these.</p>
<ul>
<li><strong>Free, in the browser:</strong> <a href="https://glyphcall-voice.pages.dev/transcribe">Glyphcall Voice: transcribe</a> is the code above as a finished page, with text, SRT and VTT downloads. There is also a <a href="https://glyphcall-voice.pages.dev/text-to-speech">text to speech page</a> that runs the open Kokoro model the same way.</li>
<li><strong>As an API:</strong> <a href="https://agent-data-tools.revmesh2074.workers.dev/tools/transcribe">/transcribe</a> runs Whisper large-v3-turbo on our servers for $0.01 per file (files up to 5 MB at a public URL). There is no account: <a href="https://agent-data-tools.revmesh2074.workers.dev/credits">card credits</a> start at $1, or an agent can pay per call in USDC over x402.</li>
</ul>
<pre><code class="language-bash">curl -H "Authorization: Bearer adt_…" \
  "https://agent-data-tools.revmesh2074.workers.dev/transcribe?url=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FSpecial%3AFilePath%2FEn-us-hello.ogg"
</code></pre>
<p>Automatic transcripts contain mistakes, wherever they run, so check names and numbers before you publish them.</p>
]]></content:encoded></item><item><title><![CDATA[Vetting TikTok and Threads creators with exact numbers: engagement rate, likes per video and the traps in rounded counts]]></title><description><![CDATA[Before paying a creator, most teams look at the follower count on the profile and maybe scroll a few posts. Both TikTok and Threads make that misleading in…]]></description><link>https://spellzcode.hashnode.dev/vetting-tiktok-and-threads-creators-with-exact-numbers-engagement-rate-likes-per-video-and-the-traps-in-rounded-counts</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/vetting-tiktok-and-threads-creators-with-exact-numbers-engagement-rate-likes-per-video-and-the-traps-in-rounded-counts</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 15:31:37 GMT</pubDate><content:encoded><![CDATA[<p>Before paying a creator, most teams look at the follower count on the profile and maybe scroll a few posts. Both TikTok and Threads make that misleading in different ways. This post covers the numbers worth computing, how to compute them, and where they lie. Disclosure: SpellzCode, the brand behind this account, sells the two scrapers used in the code (links at the end); the formulas work with any data source.</p>
<h2>Trap 1: rounded counts</h2>
<p>TikTok shows "27.4M followers" on the profile. Fine for a glance, useless for tracking: a creator can gain 49,999 followers and the number does not move. If you track growth week over week, you need the exact count. TikTok's own page data carries it (<code>27,483,982</code> in that example), so any tool you use should return that, not the rounded label.</p>
<h2>Trap 2: lifetime likes</h2>
<p>TikTok's "Likes" is a lifetime total across all videos. A creator with one viral video three years ago looks strong forever. Divide by the number of videos to get <strong>average likes per video</strong>, and compare it with followers:</p>
<pre><code class="language-js">const avgLikesPerVideo = likes / videos;
const likesPerFollower = likes / followers;
</code></pre>
<p>Some real numbers from public profiles (November 2026):</p>
<table>
<thead>
<tr>
<th>Account</th>
<th>Followers</th>
<th>Videos</th>
<th>Avg likes / video</th>
</tr>
</thead>
<tbody><tr>
<td>@nasa</td>
<td>2,183,007</td>
<td>66</td>
<td>177,239</td>
</tr>
<tr>
<td>@nba</td>
<td>27,483,982</td>
<td>25,105</td>
<td>47,141</td>
</tr>
</tbody></table>
<p>NASA has less than a tenth of the NBA's followers but gets nearly four times the likes per video, because it posts rarely and each post lands. For a sponsored video, the per-video number is what you are buying.</p>
<h2>Trap 3: engagement on Threads</h2>
<p>Threads shows followers and the latest posts, each with likes, replies, reposts and quotes. The usual engagement rate is:</p>
<pre><code class="language-js">// posts: the account's recent posts
const avg = (k) =&gt; posts.reduce((s, p) =&gt; s + (p[k] ?? 0), 0) / posts.length;
const engagementRatePercent = ((avg('likes') + avg('replies') + avg('reposts')) / followers) * 100;
</code></pre>
<p>Real examples, computed from each account's latest public posts:</p>
<table>
<thead>
<tr>
<th>Account</th>
<th>Followers</th>
<th>Avg likes</th>
<th>Engagement rate</th>
</tr>
</thead>
<tbody><tr>
<td>@mosseri</td>
<td>1,058,672</td>
<td>942</td>
<td>0.136%</td>
</tr>
<tr>
<td>@zuck</td>
<td>5,777,936</td>
<td>2,157</td>
<td>0.047%</td>
</tr>
<tr>
<td>@nasa</td>
<td>12,797,207</td>
<td>1,822</td>
<td>0.016%</td>
</tr>
<tr>
<td>@nytimes</td>
<td>4,782,467</td>
<td>22</td>
<td>0.001%</td>
</tr>
</tbody></table>
<p>The account with the fewest followers has by far the highest rate. Big brand accounts that post links all day sit near zero. Two cautions: a handful of recent posts is a small sample, and one viral post skews the average. Look at the median too if you have enough posts.</p>
<h2>Trap 4: inactive accounts</h2>
<p>A big follower count on an account that last posted months ago is worth little. Always check the date of the newest post.</p>
<h2>Doing it for a list of handles</h2>
<p>The two Apify actors below return these fields directly, one row per account. TikTok gives exact counts, <code>avgLikesPerVideo</code>, <code>likesPerFollower</code>, plus business-account and TikTok Shop seller flags. Threads gives recent posts with likes, replies, reposts and quotes, plus <code>engagementRatePercent</code> and <code>lastPostedAt</code>.</p>
<pre><code class="language-js">// npm i apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const handles = ['nasa', 'nba', 'duolingo'];

const tt = await client.actor('spellzcode/tiktok-profile-data').call({ usernames: handles });
const th = await client.actor('spellzcode/threads-profile-data').call({ usernames: handles });

const tiktok = (await client.dataset(tt.defaultDatasetId).listItems()).items;
const threads = (await client.dataset(th.defaultDatasetId).listItems()).items;

for (const h of handles) {
  const a = tiktok.find((x) =&gt; x.username === h);
  const b = threads.find((x) =&gt; x.username === h);
  console.log(h, {
    tiktokFollowers: a?.followers,
    tiktokAvgLikes: a?.avgLikesPerVideo,
    threadsFollowers: b?.followers,
    threadsEngagement: b?.engagementRatePercent,
    threadsLastPost: b?.lastPostedAt,
  });
}
</code></pre>
<p>Both cost $2 per 1,000 profiles; missing accounts are free, and Apify's free $5 monthly credit covers about 2,500 profiles. They read public pages as a logged-out visitor, without logins or proxies, so they return account-level data and the recent posts the public profile shows, not full video or post histories.</p>
<h2>Links</h2>
<ul>
<li><a href="https://apify.com/spellzcode/tiktok-profile-data">TikTok Profile Scraper</a></li>
<li><a href="https://apify.com/spellzcode/threads-profile-data">Threads Profile Scraper</a></li>
<li>Code examples: <a href="https://github.com/Nutshell2000/tiktok-profile-scraper">tiktok-profile-scraper</a>, <a href="https://github.com/Nutshell2000/threads-profile-scraper">threads-profile-scraper</a></li>
<li><a href="https://github.com/Nutshell2000/spellzcode-apify-actors">All SpellzCode Apify actors</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Your PDF-to-text pipeline is silently returning empty pages: detecting scanned PDFs and when OCR is worth it]]></title><description><![CDATA[If you feed PDFs into search, a RAG pipeline or an LLM, some of them come back with almost no text and nothing errors. Those are scanned PDFs: each page is…]]></description><link>https://spellzcode.hashnode.dev/your-pdf-to-text-pipeline-is-silently-returning-empty-pages-detecting-scanned-pdfs-and-when-ocr-is-worth-it</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/your-pdf-to-text-pipeline-is-silently-returning-empty-pages-detecting-scanned-pdfs-and-when-ocr-is-worth-it</guid><category><![CDATA[pdf]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 14:40:06 GMT</pubDate><content:encoded><![CDATA[<p>If you feed PDFs into search, a RAG pipeline or an LLM, some of them come back with almost no text and nothing errors. Those are scanned PDFs: each page is a picture of text, with no text stored in the file. This post shows how to detect them, what OCR settings matter, and what to expect from the result. Disclosure: SpellzCode, the brand behind this account, sells a PDF-to-text tool (linked at the end); the code below uses free open-source libraries.</p>
<h2>Detecting a scanned page</h2>
<p>A normal PDF page stores its text. A scanned one stores an image. So: extract the text per page and look at how much came back.</p>
<pre><code class="language-js">// npm i unpdf
import { getDocumentProxy, extractText } from 'unpdf';

const buf = new Uint8Array(await (await fetch(url)).arrayBuffer());
const pdf = await getDocumentProxy(buf);
const { text: pages } = await extractText(pdf, { mergePages: false });

const empty = pages.map((t, i) =&gt; ({ page: i + 1, chars: t.replace(/\s/g, '').length }))
  .filter((p) =&gt; p.chars &lt; 20);

const looksScanned = empty.length &gt;= pages.length * 0.9;
console.log({ pages: pages.length, emptyPages: empty.map((p) =&gt; p.page), looksScanned });
</code></pre>
<p>Three cases come out of this:</p>
<ul>
<li><strong>No empty pages:</strong> a normal PDF. Do not OCR it; the stored text is exact and OCR would only add errors.</li>
<li><strong>Every page empty:</strong> a scan. OCR it or reject it.</li>
<li><strong>Some pages empty:</strong> the common, annoying one. A typed contract with a scanned signature page, or a report with a scanned appendix. OCR only the empty pages.</li>
</ul>
<p>Mark rows instead of guessing: a downstream system should know a document's text came from OCR.</p>
<h2>OCR settings that actually matter</h2>
<p>Using Tesseract (free, via <code>tesseract.js</code> in Node):</p>
<ol>
<li><strong>Resolution.</strong> Render pages at 300 dpi (about 2,480 pixels wide for A4). In our tests at 150 dpi, digits in tables were misread regularly; at 300 dpi ordinary typefaces were read without error.</li>
<li><strong>Language.</strong> Set the document's language. With the English model, Swedish å, ä, ö or German ß come out wrong.</li>
<li><strong>Page segmentation.</strong> The default automatic mode (PSM 3) is right for normal pages. Tables come out one row per line, in reading order, not as a table.</li>
<li><strong>Confidence.</strong> Tesseract reports a confidence from 0 to 100 per page. Store it, and send low-confidence pages to a human.</li>
</ol>
<pre><code class="language-js">// npm i tesseract.js unpdf @napi-rs/canvas
import { createWorker } from 'tesseract.js';
import { renderPageAsImage } from 'unpdf';

const worker = await createWorker('eng');
for (const { page } of empty) {
  const png = await renderPageAsImage(buf, page, {
    canvasImport: () =&gt; import('@napi-rs/canvas'),
    width: 2480,
  });
  const { data } = await worker.recognize(Buffer.from(png));
  pages[page - 1] = data.text;
  console.log(`page ${page}: confidence ${data.confidence}`);
}
await worker.terminate();
</code></pre>
<h2>What to expect</h2>
<ul>
<li>Clean printed text is read reliably.</li>
<li><strong>Check numbers.</strong> In one of our test pages, a typeface whose digits vary in height (old-style figures) had a 9 read as 0. If amounts matter, as on invoices, validate them (totals should add up).</li>
<li>Handwriting, and phone photos of pages taken at an angle or in bad light, are not worth running through Tesseract.</li>
<li>OCR is slow: seconds per page on a normal CPU. That is why OCRing every page "to be safe" is a bad default.</li>
</ul>
<h2>Using the tool instead</h2>
<p><a href="https://apify.com/spellzcode/pdf-to-text-extractor">PDF Text Extractor &amp; OCR on Apify</a> does the detection and selective OCR above for a list of PDF links. It returns the text, optional per-page text marked as <code>text</code> or <code>ocr</code>, <code>looksScanned</code>, <code>ocrPageCount</code>, <code>ocrConfidence</code>, and the document's metadata:</p>
<pre><code class="language-js">// npm i apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor('spellzcode/pdf-to-text-extractor').call({
  pdfUrls: ['https://arxiv.org/pdf/1706.03762'],
  includePages: true,
  ocrScanned: true,
  ocrLanguage: 'eng',
  maxOcrPages: 50,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].pageCount, items[0].looksScanned, items[0].text.slice(0, 200));
</code></pre>
<p>It costs $5 per 1,000 PDFs, plus $8 per 1,000 pages that actually needed OCR. Broken links and password-protected files are free. Apify's free $5 monthly credit covers 1,000 ordinary PDFs or about 600 scanned pages.</p>
<h2>Links</h2>
<ul>
<li><a href="https://apify.com/spellzcode/pdf-to-text-extractor">PDF Text Extractor &amp; OCR</a></li>
<li><a href="https://github.com/Nutshell2000/spellzcode-apify-actors">All SpellzCode Apify actors</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Getting the contact email from 500 company websites: hidden addresses, junk matches and dead domains]]></title><description><![CDATA["Find the contact email on each of these websites" sounds like one regex. In practice a naive scraper gets a third of the emails wrong or misses them. This…]]></description><link>https://spellzcode.hashnode.dev/getting-the-contact-email-from-500-company-websites-hidden-addresses-junk-matches-and-dead-domains</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/getting-the-contact-email-from-500-company-websites-hidden-addresses-junk-matches-and-dead-domains</guid><category><![CDATA[email]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 14:30:51 GMT</pubDate><content:encoded><![CDATA[<p>"Find the contact email on each of these websites" sounds like one regex. In practice a naive scraper gets a third of the emails wrong or misses them. This post walks through the four problems that cause most of the misses, with code for each. Disclosure: SpellzCode, the brand behind this account, sells a tool that does all of this (linked at the end), but the techniques below stand on their own.</p>
<h2>1. The email is not on the home page</h2>
<p>Most companies put their address on a Contact, About, Team or Imprint page. Look at the home page's links and open the few most likely ones, including other languages:</p>
<pre><code class="language-js">const CONTACT_WORDS = /contact|kontakt|about|om-oss|team|imprint|impressum|mentions-legales|contacto|contatti|yhteystiedot/i;

function likelyContactPages(html, baseUrl, max = 4) {
  const links = [...html.matchAll(/href="([^"#]+)"/g)].map((m) =&gt; new URL(m[1], baseUrl));
  const same = links.filter((u) =&gt; u.hostname === new URL(baseUrl).hostname);
  return [...new Set(same.filter((u) =&gt; CONTACT_WORDS.test(u.pathname)).map(String))].slice(0, max);
}
</code></pre>
<p>Four or five pages per site finds the address on nearly every site that publishes one.</p>
<h2>2. The email is hidden by Cloudflare</h2>
<p>Sites behind Cloudflare often have "email address protection" on. The HTML then contains <code>&lt;a data-cfemail="..."&gt;[email protected]&lt;/a&gt;</code> instead of the address. It is a simple XOR: the first byte is the key.</p>
<pre><code class="language-js">function decodeCfEmail(hex) {
  const key = parseInt(hex.slice(0, 2), 16);
  let out = '';
  for (let i = 2; i &lt; hex.length; i += 2) {
    out += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16) ^ key);
  }
  return out;
}

const hidden = [...html.matchAll(/data-cfemail="([0-9a-f]+)"/gi)].map((m) =&gt; decodeCfEmail(m[1]));
</code></pre>
<p>Also read <code>name [at] company [dot] com</code> spellings, which many small sites use.</p>
<h2>3. Your regex matches junk</h2>
<p>An email regex over raw HTML returns things like <code>logo@2x.png</code>, Sentry and error-tracking addresses, <code>you@example.com</code> placeholders in forms, and <code>firstname.lastname@company.com</code> from instructions. Filter them:</p>
<pre><code class="language-js">const JUNK = [
  /\.(png|jpe?g|gif|svg|webp)$/i,          // retina image names
  /@(sentry|wixpress|example)\./i,          // tracking and placeholders
  /^(you|your|name|firstname|email)[.@]/i,  // form hints
];
const clean = (emails) =&gt; [...new Set(emails.map((e) =&gt; e.toLowerCase()))].filter((e) =&gt; !JUNK.some((r) =&gt; r.test(e)));
</code></pre>
<p>Then rank what is left: an address at the site's own domain beats a Gmail address or the web agency's address in the footer, and <code>info@</code> or <code>contact@</code> beats a named person for a first message.</p>
<h2>4. The domain cannot receive mail</h2>
<p>Old addresses on old pages point at domains that no longer have a mail server. One DNS lookup catches them before they bounce:</p>
<pre><code class="language-js">import { resolveMx } from 'node:dns/promises';

async function domainAcceptsMail(email) {
  try {
    const mx = await resolveMx(email.split('@')[1]);
    return mx.length &gt; 0;
  } catch {
    return false;
  }
}
</code></pre>
<p>This confirms the domain takes mail, not that the mailbox exists. Checking a mailbox means talking SMTP to the server, which many servers now refuse or answer falsely, so treat the MX check as the reliable part.</p>
<h2>Phones and socials</h2>
<p>Take phone numbers from <code>tel:</code> links and from the site's JSON-LD (<code>"telephone"</code>) rather than regexing digits out of text, which picks up VAT numbers and dates. Social profiles are just links to <a href="http://linkedin.com/company">linkedin.com/company</a>, <a href="http://facebook.com">facebook.com</a>, <a href="http://instagram.com">instagram.com</a> and so on.</p>
<h2>Using the tool instead</h2>
<p><a href="https://apify.com/spellzcode/website-contact-extractor">Contact Details Scraper on Apify</a> does all of the above, returning one row per website with <code>primaryEmail</code>, every email with its type and source page, phones, social links and the contact page URL:</p>
<pre><code class="language-js">// npm i apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor('spellzcode/website-contact-extractor').call({
  websites: ['apify.com', 'letsencrypt.org'],
  maxPagesPerSite: 5,
  onlyDomainEmails: true,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
for (const s of items) console.log(s.domain, s.primaryEmail, s.phones?.[0] ?? '');
</code></pre>
<p>You pay $1.50 per 1,000 websites where contacts were found; sites with nothing, or that refuse the request, are free. Apify's free $5 monthly credit covers about 3,300 sites with contacts. It reads the HTML a site serves, so contacts that only appear after JavaScript runs can be missed.</p>
<h2>Before you send anything</h2>
<p>Addresses of named people are personal data under GDPR, and many countries restrict unsolicited e-mail even to businesses. Prefer role addresses, have a lawful basis, honour opt-outs, and respect each site's terms and robots.txt (the tool does by default).</p>
<h2>Links</h2>
<ul>
<li><a href="https://apify.com/spellzcode/website-contact-extractor">Contact Details Scraper</a></li>
<li><a href="https://apify.com/spellzcode/bulk-email-list-cleaner">Email List Cleaner</a> for checking a list you already have</li>
<li><a href="https://github.com/Nutshell2000/spellzcode-apify-actors">All SpellzCode Apify actors</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Every new Swedish company from the last 30 days as a spreadsheet, from Bolagsverket's open data]]></title><description><![CDATA[About 4,500 to 6,000 companies are registered in Sweden every month. If you sell accounting, banking, insurance, payments, web design or office space…]]></description><link>https://spellzcode.hashnode.dev/every-new-swedish-company-from-the-last-30-days-as-a-spreadsheet-from-bolagsverket-s-open-data</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/every-new-swedish-company-from-the-last-30-days-as-a-spreadsheet-from-bolagsverket-s-open-data</guid><category><![CDATA[Sweden]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 14:29:12 GMT</pubDate><content:encoded><![CDATA[<p>About 4,500 to 6,000 companies are registered in Sweden every month. If you sell accounting, banking, insurance, payments, web design or office space, those first weeks are when a new company picks its suppliers. Sites like Allabolag show the data one company at a time; this post shows how to get the whole list from the official source instead, what is in it, and what is not.</p>
<p>Disclosure: SpellzCode, the brand behind this account, makes a paid tool that does this (linked at the end). Everything before that section works without it.</p>
<h2>The source: Bolagsverket and SCB open data</h2>
<p>The Swedish Companies Registration Office (Bolagsverket) and Statistics Sweden (SCB) publish their company registers as open data under the EU high-value datasets rules ("värdefulla datamängder"). That means:</p>
<ul>
<li>free to download and <strong>free to reuse commercially</strong></li>
<li>a <strong>weekly</strong> bulk file, not a live API</li>
<li>every registered company: name, organisationsnummer, legal form, registration date, status, SNI industry codes, the business description from the articles of association, and postal address</li>
</ul>
<p>What it does <strong>not</strong> contain: phone numbers, e-mail addresses, websites, board members, owners or financial figures. Sole traders (enskild firma) are left out of the company file too.</p>
<h2>Freshness: the part people get wrong</h2>
<p>A new registration reaches the weekly file roughly one to two weeks after it happened. So "registered in the last 7 days" will look nearly empty. Use 30 days or more and run it weekly, keeping the rows you have not seen before.</p>
<p>Industry codes (SNI) are assigned by SCB some weeks after registration. Of companies registered in the last six weeks, only about one in four has a code yet. For brand-new companies, filter on city, postcode or words in the name or business description instead of SNI.</p>
<h2>Checking an organisationsnummer</h2>
<p>If you merge this list with your CRM, validate the numbers first. A Swedish organisationsnummer is ten digits with a Luhn check digit, and the third digit is 2 or higher for companies (lower means a personal number).</p>
<pre><code class="language-js">function isSwedishOrgNr(input) {
  const d = input.replace(/\D/g, '').slice(-10);
  if (d.length !== 10 || Number(d[2]) &lt; 2) return false;
  let sum = 0;
  for (let i = 0; i &lt; 10; i++) {
    let n = Number(d[i]) * (i % 2 === 0 ? 2 : 1);
    sum += n &gt; 9 ? n - 9 : n;
  }
  return sum % 10 === 0;
}

isSwedishOrgNr('556703-7485'); // true (Spotify AB)
</code></pre>
<p>The VAT number is then <code>SE</code> + the ten digits + <code>01</code>.</p>
<h2>Useful SNI prefixes</h2>
<table>
<thead>
<tr>
<th>Prefix</th>
<th>Industry</th>
</tr>
</thead>
<tbody><tr>
<td><code>62</code></td>
<td>IT services and consulting</td>
</tr>
<tr>
<td><code>47</code></td>
<td>Retail</td>
</tr>
<tr>
<td><code>56.1</code></td>
<td>Restaurants</td>
</tr>
<tr>
<td><code>43</code></td>
<td>Specialised construction (electricians, plumbers, painters)</td>
</tr>
<tr>
<td><code>68</code></td>
<td>Real estate</td>
</tr>
<tr>
<td><code>69.2</code></td>
<td>Accounting and bookkeeping</td>
</tr>
<tr>
<td><code>86</code></td>
<td>Health care</td>
</tr>
</tbody></table>
<p>A company can have several codes; match if any of them starts with your prefix.</p>
<h2>Doing it yourself vs. using a tool</h2>
<p>Doing it yourself means downloading the weekly files from Bolagsverket and SCB, joining them on organisationsnummer, parsing the addresses and codes, and re-running each week. It is a few hours of work and then a small job to maintain.</p>
<p>If you would rather not, our Apify actor <a href="https://apify.com/spellzcode/sweden-new-companies-leads">Sweden New Companies &amp; Company Lists</a> does the join and filtering and returns rows like this:</p>
<pre><code class="language-json">{
  "companyId": "556703-7485",
  "vatNumber": "SE556703748501",
  "name": "Spotify AB",
  "legalFormCode": "AB",
  "registered": "2006-05-10",
  "industryCodes": [{ "code": "60.100" }],
  "businessDescription": "Bolaget har till föremål för sin verksamhet att ...",
  "address": { "street": "Regeringsgatan 19", "postcode": "11153", "city": "STOCKHOLM" },
  "dataAsOf": "2026-11-09"
}
</code></pre>
<p>Calling it from Node:</p>
<pre><code class="language-js">// npm i apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor('spellzcode/sweden-new-companies-leads').call({
  registeredLastDays: 30,
  legalForms: ['AB'],
  cities: ['Göteborg'],
  maxResults: 1000,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length, 'new limited companies in Göteborg');
</code></pre>
<p>It costs $3 per 1,000 companies, and Apify's free $5 monthly credit covers about 1,600. Without code: open the actor page, set the filters, run, and export CSV or Excel. To get a weekly feed, schedule it in Apify and send new rows to a sheet or CRM.</p>
<h2>Marketing rules still apply</h2>
<p>Company data is not personal data in itself, but for one-person companies the line blurs: an e-mail to the owner of a tiny company can count as marketing to an individual. SCB also keeps an advertising block list (reklamspärr) that is not in the open data. Check the rules for your channel before you send anything.</p>
<h2>Links</h2>
<ul>
<li><a href="https://apify.com/spellzcode/sweden-new-companies-leads">Sweden New Companies &amp; Company Lists on Apify</a></li>
<li><a href="https://apify.com/spellzcode/sweden-company-register-lookup">Swedish Company Register Lookup</a> for checking a list of org.nr or VAT numbers you already have</li>
<li><a href="https://github.com/Nutshell2000/spellzcode-apify-actors">All SpellzCode Apify actors</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Keep your CRM's job titles current from LinkedIn profile links, without logging in or using cookies]]></title><description><![CDATA[People change jobs, and a CRM full of stale titles quietly ruins outreach and account reports. If you already have the LinkedIn profile links of your…]]></description><link>https://spellzcode.hashnode.dev/keep-your-crm-s-job-titles-current-from-linkedin-profile-links-without-logging-in-or-using-cookies</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/keep-your-crm-s-job-titles-current-from-linkedin-profile-links-without-logging-in-or-using-cookies</guid><category><![CDATA[LinkedIn]]></category><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 14:18:57 GMT</pubDate><content:encoded><![CDATA[<p>People change jobs, and a CRM full of stale titles quietly ruins outreach and account reports. If you already have the LinkedIn profile links of your contacts (most CRMs store them), you can refresh titles and companies on a schedule from the <strong>public</strong> profile pages, without logging in to LinkedIn and without handing over your session cookie.</p>
<p>This post covers what a public profile actually shows, what goes wrong, and a working script. Disclosure: I make the tool used in the script (a pay-per-result Apify actor from SpellzCode). The approach and the caveats apply whatever tool you use.</p>
<h2>Why not use your own LinkedIn session?</h2>
<p>Many scrapers ask for your <code>li_at</code> cookie. That works until LinkedIn notices automated traffic on your account, and then it is your personal account that gets restricted. Reading only logged-out public pages keeps your account out of it entirely. The trade-off is less data and some refusals, covered below.</p>
<h2>What a public profile shows</h2>
<p>Logged out, a profile page usually shows:</p>
<ul>
<li>name and headline (the job titles)</li>
<li>location and follower count</li>
<li>the "About" text</li>
<li><strong>some</strong> experience and education entries, often only the current one or a few</li>
</ul>
<p>It does not show emails or phone numbers, and many people limit their public profile, so fields can be empty. For "is this person still at Acme, and what is their title now?" it is enough most of the time.</p>
<h2>What goes wrong</h2>
<ol>
<li><strong>Refusals.</strong> LinkedIn refuses a share of logged-out requests. In our own test 4 of 11 pages were refused. Treat a refusal as "try again later", not as "profile gone".</li>
<li><strong>Partly hidden text.</strong> LinkedIn sometimes blurs parts of the public page. A good parser marks those rows instead of returning garbage.</li>
<li><strong>Vanity URL changes.</strong> People rename their profile URL. A 404 is a signal to look the contact up again.</li>
</ol>
<p>So design the refresh as an incremental job: update rows that came back <code>ok</code>, queue <code>refused</code> rows for the next run, and flag <code>not_found</code> rows for a human.</p>
<h2>The script</h2>
<p>This reads a CSV with a <code>linkedin</code> column, fetches the public profiles, and writes a CSV of changes to review before importing into your CRM.</p>
<pre><code class="language-js">// npm i apify-client csv-parse csv-stringify
import fs from 'node:fs';
import { parse } from 'csv-parse/sync';
import { stringify } from 'csv-stringify/sync';
import { ApifyClient } from 'apify-client';

const contacts = parse(fs.readFileSync('contacts.csv'), { columns: true });
const links = contacts.map((c) =&gt; c.linkedin).filter(Boolean);

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('spellzcode/linkedin-profile-data').call({ profiles: links });
const { items } = await client.dataset(run.defaultDatasetId).listItems();

const byUrl = new Map(items.map((p) =&gt; [p.query, p]));
const changes = [];
const retry = [];

for (const c of contacts) {
  const p = byUrl.get(c.linkedin);
  if (!p) continue;
  if (p.status === 'refused') { retry.push(c.linkedin); continue; }
  if (p.status !== 'ok') { changes.push({ ...c, note: p.status }); continue; }

  const current = p.experience?.find((e) =&gt; e.to === null);
  const newTitle = p.jobTitles?.[0] ?? '';
  const newCompany = current?.name ?? '';
  if (newTitle !== c.title || (newCompany &amp;&amp; newCompany !== c.company)) {
    changes.push({ ...c, newTitle, newCompany, note: p.partlyHidden ? 'partly hidden' : '' });
  }
}

fs.writeFileSync('changes.csv', stringify(changes, { header: true }));
fs.writeFileSync('retry.txt', retry.join('\n'));
console.log(`${changes.length} changes, ${retry.length} to retry next run`);
</code></pre>
<p>Run it weekly (cron, GitHub Actions, or Apify's own scheduler) and feed <code>retry.txt</code> back in next time.</p>
<h2>No-code version</h2>
<p>If you do not want to run code: open the actor's page on Apify, paste your profile links into the <strong>Profiles</strong> field, run it, and export the results as CSV or Excel. Apify also connects to Make, Zapier and n8n if you want the refresh to write straight into a sheet or CRM.</p>
<h2>Cost</h2>
<p>The actor charges per profile returned: $3 per 1,000 on Apify's free plan, less on paid plans. Refused and unavailable pages cost nothing. Apify's free plan includes $5 of monthly credit, which covers roughly 1,600 profiles a month.</p>
<h2>The legal part</h2>
<p>Job titles of named people are personal data. Under GDPR and similar laws you need a lawful basis (keeping data about existing business contacts accurate is a common one), you should keep only what you need, and you must honour objections and deletion requests. Do not use this for spam or for decisions like hiring without meeting the rules that apply. You are also responsible for respecting LinkedIn's terms.</p>
<h2>Links</h2>
<ul>
<li>The actor: <a href="https://apify.com/spellzcode/linkedin-profile-data">https://apify.com/spellzcode/linkedin-profile-data</a></li>
<li>Our other Apify tools (TikTok and Threads profiles, company registers, contact details, jobs and more): <a href="https://github.com/Nutshell2000/spellzcode-apify-actors">https://github.com/Nutshell2000/spellzcode-apify-actors</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Company numbers in Sweden, Norway, Finland and France: formats, check digits, and the VAT number hiding inside]]></title><description><![CDATA[Sweden, Norway, Finland and France each give a company one number, and each number ends in a check digit. If you take company numbers in a form…]]></description><link>https://spellzcode.hashnode.dev/company-numbers-in-sweden-norway-finland-and-france-formats-check-digits-and-the-vat-number-hiding-inside</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/company-numbers-in-sweden-norway-finland-and-france-formats-check-digits-and-the-vat-number-hiding-inside</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 09:30:12 GMT</pubDate><content:encoded><![CDATA[<p>Sweden, Norway, Finland and France each give a company one number, and each number ends in a check digit. If you take company numbers in a form (onboarding, invoicing, a CRM import), you can catch most typos before you ever call a register. This post has the format of each number, the check-digit rule, how the VAT number is built from it, and tested JavaScript for all of it.</p>
<p>Disclosure up front: we build a company check API at SpellzCode, and it shows up at the end. Everything before that works without it.</p>
<h2>The four numbers at a glance</h2>
<table>
<thead>
<tr>
<th>Country</th>
<th>Name</th>
<th>Format</th>
<th>Check digit</th>
<th>Example</th>
</tr>
</thead>
<tbody><tr>
<td>Sweden</td>
<td>organisationsnummer</td>
<td>10 digits, written NNNNNN-NNNN</td>
<td>Luhn (mod 10) over all ten digits</td>
<td>556703-7485</td>
</tr>
<tr>
<td>Norway</td>
<td>organisasjonsnummer</td>
<td>9 digits, the first 8 or 9</td>
<td>mod 11, weights 3 2 7 6 5 4 3 2</td>
<td>923609016</td>
</tr>
<tr>
<td>Finland</td>
<td>Y-tunnus (business ID)</td>
<td>7 digits, a hyphen, a check digit</td>
<td>mod 11, weights 7 9 10 5 8 4 2</td>
<td>0112038-9</td>
</tr>
<tr>
<td>France</td>
<td>SIREN (company), SIRET (establishment)</td>
<td>9 digits; 14 digits</td>
<td>Luhn (mod 10)</td>
<td>552032534</td>
</tr>
</tbody></table>
<p>The examples are the public register numbers of Spotify AB, Equinor ASA, Nokia Oyj and Danone.</p>
<h2>The check digits in code</h2>
<pre><code class="language-js">const digits = (s) =&gt; String(s).replace(/\D/g, "").split("").map(Number);

function luhn(ds) {
  const sum = [...ds].reverse().reduce(
    (acc, n, i) =&gt; acc + (i % 2 ? (n * 2 &gt; 9 ? n * 2 - 9 : n * 2) : n), 0);
  return sum % 10 === 0;
}

function mod11(ds, weights) {
  const rest = 11 - (weights.reduce((acc, w, i) =&gt; acc + w * ds[i], 0) % 11);
  if (rest === 10) return false; // no valid check digit exists for this body
  return (rest === 11 ? 0 : rest) === ds[weights.length];
}

// Sweden: 10 digits, Luhn over all ten.
const isSwedishOrgNumber = (s) =&gt; { const d = digits(s); return d.length === 10 &amp;&amp; luhn(d); };

// Norway: 9 digits, mod 11 with weights 3 2 7 6 5 4 3 2.
const isNorwegianOrgNumber = (s) =&gt; { const d = digits(s); return d.length === 9 &amp;&amp; mod11(d, [3, 2, 7, 6, 5, 4, 3, 2]); };

// Finland: 7 digits + check digit, mod 11 with weights 7 9 10 5 8 4 2.
const isFinnishBusinessId = (s) =&gt; { const d = digits(s); return d.length === 8 &amp;&amp; mod11(d, [7, 9, 10, 5, 8, 4, 2]); };

// France: SIREN (9 digits) and SIRET (14 digits), both Luhn.
const isSiren = (s) =&gt; { const d = digits(s); return d.length === 9 &amp;&amp; luhn(d); };
const isSiret = (s) =&gt; { const d = digits(s); return d.length === 14 &amp;&amp; luhn(d); };
</code></pre>
<p>Two details that are easy to get wrong:</p>
<ul>
<li><strong>Mod 11 can have no answer.</strong> When the remainder calls for a check digit of 10, that number body is simply never issued. Return false; do not map 10 to 0.</li>
<li><strong>The Swedish Luhn runs over the 10-digit form.</strong> Swedish numbers are sometimes written with a century prefix (12 digits, <code>16</code> for companies). Strip it before checking.</li>
</ul>
<h2>From company number to VAT number</h2>
<p>In three of the four countries the VAT number is the company number in a wrapper, so you can derive one from the other.</p>
<pre><code class="language-js">const swedishVat   = (org)   =&gt; `SE${digits(org).join("")}01`;      // 556703-7485 -&gt; SE556703748501
const finnishVat   = (id)    =&gt; `FI${digits(id).join("")}`;         // 0112038-9   -&gt; FI01120389
const norwegianVat = (org)   =&gt; `NO${digits(org).join("")}MVA`;     // 923609016   -&gt; NO923609016MVA
const frenchVat    = (siren) =&gt; {
  const n = Number(digits(siren).join(""));
  const key = (12 + 3 * (n % 97)) % 97;                             // 552032534   -&gt; FR27552032534
  return `FR${String(key).padStart(2, "0")}${n}`;
};
</code></pre>
<p>Caveats:</p>
<ul>
<li><strong>Deriving a VAT number does not mean the company is registered for VAT.</strong> A Swedish company without VAT registration still has an organisationsnummer. Check the derived number before you rely on it.</li>
<li><strong>Norway is not in the EU</strong>, so a Norwegian number cannot be checked in VIES. The Norwegian register itself says whether the company is in the VAT register; the <code>MVA</code> suffix on an invoice means it is.</li>
<li><strong>French keys for newer companies can contain letters.</strong> The formula above gives the numeric key that the large majority of companies have.</li>
</ul>
<h2>What a check digit cannot tell you</h2>
<p>A number that passes is well formed. It may still belong to nobody, or to a company that was dissolved last year. For that you need the register:</p>
<ul>
<li>Sweden: Bolagsverket (and SCB for activity data)</li>
<li>Norway: Brønnøysundregistrene</li>
<li>Finland: PRH, the Patent and Registration Office</li>
<li>France: INSEE's Sirene register and the national business register</li>
</ul>
<p>All four publish their data openly, each in its own format and with its own quirks, which is the tedious part.</p>
<h2>If you would rather not integrate four registers</h2>
<p>This is where our own tool comes in. One GET request per country, the same shape of JSON back: names, legal form, status, bankruptcy or liquidation, registration date, industry codes and address. Register facts only: no credit scores and no personal data about owners.</p>
<pre><code class="language-bash">curl -H "Authorization: Bearer $API_KEY" \
  "https://tools.funwords.eu/no/company?orgnr=923609016"
</code></pre>
<p>There is a page per country with the format, the check digit and a free lookup form: <a href="https://tools.funwords.eu/company-register">Company register lookup</a>. VAT numbers for every EU country are covered in <a href="https://tools.funwords.eu/vat-number-check">the VAT number check</a>, and the API with plans is at <a href="https://tools.funwords.eu/company-check-api">Company check API</a>.</p>
<p>If you only need the check digits, the code above is all you need. If a rule here is wrong for some class of numbers, say so in the comments and we will fix the post. </p>
]]></content:encoded></item><item><title><![CDATA[EU VAT number formats for every country (with regex), and what a VIES check really tells you]]></title><description><![CDATA[If you sell to businesses in the EU, sooner or later you have to check a customer's VAT number: at checkout, before you zero-rate an invoice, or when you…]]></description><link>https://spellzcode.hashnode.dev/eu-vat-number-formats-for-every-country-with-regex-and-what-a-vies-check-really-tells-you</link><guid isPermaLink="true">https://spellzcode.hashnode.dev/eu-vat-number-formats-for-every-country-with-regex-and-what-a-vies-check-really-tells-you</guid><dc:creator><![CDATA[SpellzCode]]></dc:creator><pubDate>Sat, 14 Nov 2026 07:54:37 GMT</pubDate><content:encoded><![CDATA[<p>If you sell to businesses in the EU, sooner or later you have to check a customer's VAT number: at checkout, before you zero-rate an invoice, or when you clean up a customer list. This post is the reference we wanted while building a VAT check: the format of every country's number, a regex for each, and what a live check against the EU's VIES service actually tells you.</p>
<p>Disclosure up front: we build a small VAT and company check API at SpellzCode, and it shows up near the end. Everything before that works without it.</p>
<h2>Two different checks</h2>
<p>A VAT number can be wrong in two ways.</p>
<ol>
<li><strong>It is malformed.</strong> A digit is missing, or the prefix is wrong. You can catch this offline with a pattern.</li>
<li><strong>It is well formed but not registered.</strong> Only the member state's tax database knows. The EU exposes those databases through VIES (VAT Information Exchange System).</li>
</ol>
<p>Do the first check in your form, so people get instant feedback. Do the second on your server before you rely on the number.</p>
<h2>The format of every VIES country</h2>
<p>Strip spaces, dots and hyphens and uppercase the input first. People type <code>DE 123 456 789</code> and <code>se556703-7485 01</code>.</p>
<table>
<thead>
<tr>
<th>Country</th>
<th>Prefix</th>
<th>After the prefix</th>
<th>Regex</th>
</tr>
</thead>
<tbody><tr>
<td>Austria</td>
<td>AT</td>
<td>the letter U and 8 digits</td>
<td><code>^ATU\d{8}$</code></td>
</tr>
<tr>
<td>Belgium</td>
<td>BE</td>
<td>10 digits, the first 0 or 1</td>
<td><code>^BE[01]\d{9}$</code></td>
</tr>
<tr>
<td>Bulgaria</td>
<td>BG</td>
<td>9 or 10 digits</td>
<td><code>^BG\d{9,10}$</code></td>
</tr>
<tr>
<td>Cyprus</td>
<td>CY</td>
<td>8 digits and a letter</td>
<td><code>^CY\d{8}[A-Z]$</code></td>
</tr>
<tr>
<td>Czech Republic</td>
<td>CZ</td>
<td>8, 9 or 10 digits</td>
<td><code>^CZ\d{8,10}$</code></td>
</tr>
<tr>
<td>Germany</td>
<td>DE</td>
<td>9 digits</td>
<td><code>^DE\d{9}$</code></td>
</tr>
<tr>
<td>Denmark</td>
<td>DK</td>
<td>8 digits</td>
<td><code>^DK\d{8}$</code></td>
</tr>
<tr>
<td>Estonia</td>
<td>EE</td>
<td>9 digits</td>
<td><code>^EE\d{9}$</code></td>
</tr>
<tr>
<td>Greece</td>
<td>EL</td>
<td>9 digits</td>
<td><code>^EL\d{9}$</code></td>
</tr>
<tr>
<td>Spain</td>
<td>ES</td>
<td>9 characters: a letter or digit, 7 digits, a letter or digit</td>
<td><code>^ES[A-Z0-9]\d{7}[A-Z0-9]$</code></td>
</tr>
<tr>
<td>Finland</td>
<td>FI</td>
<td>8 digits</td>
<td><code>^FI\d{8}$</code></td>
</tr>
<tr>
<td>France</td>
<td>FR</td>
<td>a 2-character key (digits, or letters other than O and I) and the 9-digit SIREN</td>
<td><code>^FR[0-9A-HJ-NP-Z]{2}\d{9}$</code></td>
</tr>
<tr>
<td>Croatia</td>
<td>HR</td>
<td>11 digits</td>
<td><code>^HR\d{11}$</code></td>
</tr>
<tr>
<td>Hungary</td>
<td>HU</td>
<td>8 digits</td>
<td><code>^HU\d{8}$</code></td>
</tr>
<tr>
<td>Ireland</td>
<td>IE</td>
<td>7 digits and 1 or 2 letters, or the older form: a digit, a letter or + or *, 5 digits and a letter</td>
<td><code>^IE(\d{7}[A-Z]{1,2}|\d[A-Z+*]\d{5}[A-Z])$</code></td>
</tr>
<tr>
<td>Italy</td>
<td>IT</td>
<td>11 digits</td>
<td><code>^IT\d{11}$</code></td>
</tr>
<tr>
<td>Lithuania</td>
<td>LT</td>
<td>9 or 12 digits</td>
<td><code>^LT(\d{9}|\d{12})$</code></td>
</tr>
<tr>
<td>Luxembourg</td>
<td>LU</td>
<td>8 digits</td>
<td><code>^LU\d{8}$</code></td>
</tr>
<tr>
<td>Latvia</td>
<td>LV</td>
<td>11 digits</td>
<td><code>^LV\d{11}$</code></td>
</tr>
<tr>
<td>Malta</td>
<td>MT</td>
<td>8 digits</td>
<td><code>^MT\d{8}$</code></td>
</tr>
<tr>
<td>Netherlands</td>
<td>NL</td>
<td>9 digits, the letter B and 2 digits</td>
<td><code>^NL\d{9}B\d{2}$</code></td>
</tr>
<tr>
<td>Poland</td>
<td>PL</td>
<td>10 digits</td>
<td><code>^PL\d{10}$</code></td>
</tr>
<tr>
<td>Portugal</td>
<td>PT</td>
<td>9 digits</td>
<td><code>^PT\d{9}$</code></td>
</tr>
<tr>
<td>Romania</td>
<td>RO</td>
<td>2 to 10 digits</td>
<td><code>^RO\d{2,10}$</code></td>
</tr>
<tr>
<td>Sweden</td>
<td>SE</td>
<td>12 digits: the 10-digit organisationsnummer followed by 01</td>
<td><code>^SE\d{12}$</code></td>
</tr>
<tr>
<td>Slovenia</td>
<td>SI</td>
<td>8 digits</td>
<td><code>^SI\d{8}$</code></td>
</tr>
<tr>
<td>Slovakia</td>
<td>SK</td>
<td>10 digits</td>
<td><code>^SK\d{10}$</code></td>
</tr>
<tr>
<td>Northern Ireland</td>
<td>XI</td>
<td>9 or 12 digits, or GD or HA and 3 digits</td>
<td><code>^XI(\d{9}|\d{12}|(GD|HA)\d{3})$</code></td>
</tr>
</tbody></table>
<p>As a JavaScript object:</p>
<pre><code class="language-js">const VAT_PATTERNS = {
  AT: /^ATU\d{8}$/,
  BE: /^BE[01]\d{9}$/,
  BG: /^BG\d{9,10}$/,
  CY: /^CY\d{8}[A-Z]$/,
  CZ: /^CZ\d{8,10}$/,
  DE: /^DE\d{9}$/,
  DK: /^DK\d{8}$/,
  EE: /^EE\d{9}$/,
  EL: /^EL\d{9}$/,
  ES: /^ES[A-Z0-9]\d{7}[A-Z0-9]$/,
  FI: /^FI\d{8}$/,
  FR: /^FR[0-9A-HJ-NP-Z]{2}\d{9}$/,
  HR: /^HR\d{11}$/,
  HU: /^HU\d{8}$/,
  IE: /^IE(\d{7}[A-Z]{1,2}|\d[A-Z+*]\d{5}[A-Z])$/,
  IT: /^IT\d{11}$/,
  LT: /^LT(\d{9}|\d{12})$/,
  LU: /^LU\d{8}$/,
  LV: /^LV\d{11}$/,
  MT: /^MT\d{8}$/,
  NL: /^NL\d{9}B\d{2}$/,
  PL: /^PL\d{10}$/,
  PT: /^PT\d{9}$/,
  RO: /^RO\d{2,10}$/,
  SE: /^SE\d{12}$/,
  SI: /^SI\d{8}$/,
  SK: /^SK\d{10}$/,
  XI: /^XI(\d{9}|\d{12}|(GD|HA)\d{3})$/,
};

function looksLikeVat(input) {
  const vat = input.toUpperCase().replace(/[\s.\-]/g, "").replace(/^GR/, "EL");
  const pattern = VAT_PATTERNS[vat.slice(0, 2)];
  return Boolean(pattern &amp;&amp; pattern.test(vat));
}
</code></pre>
<h2>Things that trip people up</h2>
<ul>
<li><strong>Greece is EL, not GR.</strong> VIES uses EL. Accept GR from users and convert it.</li>
<li><strong>Northern Ireland is XI.</strong> Since Brexit, GB numbers are not in VIES. Only Northern Ireland businesses trading in goods have an XI number.</li>
<li><strong>Germany and Spain return no name or address.</strong> A VIES check for a DE or ES number tells you valid or not valid and nothing else. Do not build a flow that needs the company name for those two.</li>
<li><strong>The German Steuernummer is not the VAT number.</strong> Invoices often carry both. Only the USt-IdNr. (DE plus 9 digits) can be checked.</li>
<li><strong>Sweden, Finland and France embed the company number.</strong> A Swedish VAT number is the 10-digit organisationsnummer plus 01. A Finnish one is the business ID without its hyphen. A French one is a 2-character key plus the 9-digit SIREN, and the key is <code>(12 + 3 * (SIREN % 97)) % 97</code>.</li>
<li><strong>A pattern match is not a registration.</strong> <code>DE123456789</code> matches the German pattern and is not a real company.</li>
</ul>
<h2>The live check</h2>
<p>VIES has a SOAP service and, more recently, a REST endpoint. Both work, and both have the same operational quirk: each member state runs its own backend, and they go down or refuse concurrent requests independently. You will see answers like <code>MS_UNAVAILABLE</code> and <code>MS_MAX_CONCURRENT_REQ</code>.</p>
<p>The rule that matters: <strong>an error is not "not valid".</strong> If Germany's backend is busy, you know nothing about the number. Retry with a short backoff, and if you still have no answer, tell the user you could not check it. Never reject a customer because VIES timed out.</p>
<p>Cache positive answers for a while. A number that was valid ten minutes ago is almost certainly still valid, and VIES is not fast.</p>
<h2>If you would rather not run that yourself</h2>
<p>This is the part where our own tool comes in. We wrapped the above (normalising input, retrying busy member states, caching clear answers, never turning an outage into "not valid") into one GET request:</p>
<pre><code class="language-bash">curl -H "Authorization: Bearer $API_KEY" \
  "https://tools.funwords.eu/vat/validate?vat=SE556703748501"
</code></pre>
<pre><code class="language-json">{
  "vat": "SE556703748501",
  "country": "SE",
  "number": "556703748501",
  "valid": true,
  "name": "Spotify AB",
  "address": "REGERINGSGATAN 19, 111 53 STOCKHOLM",
  "source": "EU VIES (European Commission)"
}
</code></pre>
<p>A failed check answers with a 5xx and is not charged, so your code can treat it as "no answer". There is a free check form and a page per country (format, local name, the quirks above) here: <a href="https://tools.funwords.eu/vat-number-check">EU VAT number check</a>. The API itself, with Python, Node.js and PHP examples, is here: <a href="https://tools.funwords.eu/company-check-api">Company check API</a>. It also looks companies up in the Swedish, Norwegian, Finnish and French registers.</p>
<p>If you only need the format check, the table above is all you need. Corrections are welcome in the comments: tax authorities change formats now and then, and we would rather fix the table than leave a wrong regex on the internet. </p>
]]></content:encoded></item></channel></rss>