<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sheng Shijie</title>
    <description>The latest articles on DEV Community by Sheng Shijie (@fengyue).</description>
    <link>https://dev.to/fengyue</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4204140%2F68b9492d-e9fa-4cdb-baed-0a974a4f00d3.png</url>
      <title>DEV Community: Sheng Shijie</title>
      <link>https://dev.to/fengyue</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fengyue"/>
    <language>en</language>
    <item>
      <title>Why your scraper breaks every time a site is redesigned — and how to make it heal itself</title>
      <dc:creator>Sheng Shijie</dc:creator>
      <pubDate>Sat, 24 Oct 2026 07:39:03 +0000</pubDate>
      <link>https://dev.to/fengyue/why-your-scraper-breaks-every-time-a-site-is-redesigned-and-how-to-make-it-heal-itself-44op</link>
      <guid>https://dev.to/fengyue/why-your-scraper-breaks-every-time-a-site-is-redesigned-and-how-to-make-it-heal-itself-44op</guid>
      <description>&lt;p&gt;Every scraper I've ever written died the same death. Not with an error — with&lt;br&gt;
silence. The site shipped a redesign, my CSS selectors matched nothing, and the&lt;br&gt;
script kept running and returning empty fields. I'd notice days later when the&lt;br&gt;
data looked wrong.&lt;/p&gt;

&lt;p&gt;The usual fixes all have a catch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hand-written selectors&lt;/strong&gt; are free and fast, but every redesign means a
manual rewrite. The maintenance never ends.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud "AI scraping" services&lt;/strong&gt; are robust, but they're expensive, they send
the pages you're scraping through someone else's servers, and they run a model
call on &lt;em&gt;every single request&lt;/em&gt; — your bill scales with your crawl.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted the robustness of the AI approach without paying for it on every page.&lt;br&gt;
So I built &lt;a href="https://github.com/FengYue427/scrapemend" rel="noopener noreferrer"&gt;scrapemend&lt;/a&gt; around one&lt;br&gt;
idea: &lt;strong&gt;treat a broken selector as a cache miss, not a crash.&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  How it works
&lt;/h4&gt;

&lt;p&gt;You describe &lt;em&gt;what&lt;/em&gt; you want in plain language — no selectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scrapemend&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Scraper&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Schema&lt;/span&gt;

&lt;span class="n"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;product&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;the product name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;the product price with currency&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;scraper&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Scraper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scraper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://shop.example/p/1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;extract(url, schema)
      │
      ├─ cached selectors exist? ──► apply them
      │                               ├─ all fields matched ──► return (free)
      │                               └─ some field missed ──┐
      │                                                      ▼
      └─ no cache ─────────────────────────────────► LLM heals selectors
                                                      apply, cache, return
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The LLM only runs when selectors are missing or have stopped matching. In the&lt;br&gt;
steady state, extraction is just parsing — zero tokens. You pay the model&lt;br&gt;
exactly when a site actually changes, and the repaired selectors are cached so&lt;br&gt;
the next run is free again.&lt;/p&gt;
&lt;h4&gt;
  
  
  Does it actually survive a redesign?
&lt;/h4&gt;

&lt;p&gt;Here's a real run against two versions of the same page — same &lt;code&gt;Schema&lt;/code&gt;, no code&lt;br&gt;
changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run 1 — first visit, no cache        -&amp;gt; HEALED,     178 tokens
Run 2 — same markup again            -&amp;gt; CACHE HIT,     0 tokens
Run 3 — site redesigned (new markup) -&amp;gt; HEALED,     190 tokens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run 2 is the whole point: once selectors are known, you're not paying anything.&lt;br&gt;
Run 3 is the other half: when the markup changed and the cached selectors broke,&lt;br&gt;
it repaired itself and still returned the right data.&lt;/p&gt;

&lt;p&gt;Before the LLM ever sees a page, the HTML is condensed — scripts, styles, and&lt;br&gt;
noise attributes are stripped, keeping only structure and &lt;code&gt;class&lt;/code&gt;/&lt;code&gt;id&lt;/code&gt;. On a&lt;br&gt;
typical bloated page that cut the prompt by over 90%, which keeps healing cheap.&lt;/p&gt;

&lt;h4&gt;
  
  
  Try it
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;scrapemend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It ships with an offline stub so the pipeline runs with no API key, and&lt;br&gt;
provider adapters for OpenAI and DeepSeek when you want real healing. DeepSeek&lt;br&gt;
in particular makes healing almost free.&lt;/p&gt;

&lt;p&gt;Code and docs: &lt;a href="https://github.com/FengYue427/scrapemend" rel="noopener noreferrer"&gt;https://github.com/FengYue427/scrapemend&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's early (&lt;code&gt;0.0.1&lt;/code&gt;) and I'd genuinely like feedback on where it breaks. If&lt;br&gt;
you've ever lost a day to a silent scraper, I'd love to know whether this&lt;br&gt;
approach holds up on the sites you work with.&lt;/p&gt;

</description>
      <category>python</category>
      <category>webscraping</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
