---
type: "Source File"
title: "import re"
description: "import re db_path = \"/home/ben/infra/copecheck/db.py\" with open(db_path, \"r\") as f: content = f.read() old = '''def insert_pending(url, title, source, published, snippet, body): # Dedup: exact URL if exists(url):'''."
resource: "https://www.copecheck.com"
tags: ["copecheck", "main", "source-file", "py"]
timestamp: "2026-05-09T21:42:01Z"
site: "main"
source_path: "copecheck/fix_ingest_html.py"
---

# import re

Source path: `copecheck/fix_ingest_html.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-05-09T21:42:01Z`

```py
import re

db_path = "/home/ben/infra/copecheck/db.py"
with open(db_path, "r") as f:
    content = f.read()

old = '''def insert_pending(url, title, source, published, snippet, body):
    # Dedup: exact URL
    if exists(url):'''

new = '''def _strip_html(text):
    """Remove HTML tags from text (e.g. <b>AI</b> -> AI)."""
    if not text:
        return text
    return re.sub(r'<[^>]+>', '', text)


def insert_pending(url, title, source, published, snippet, body):
    title = _strip_html(title)
    # Dedup: exact URL
    if exists(url):'''

if old in content:
    content = content.replace(old, new)
    with open(db_path, "w") as f:
        f.write(content)
    print("Added HTML stripping to insert_pending")
else:
    print("ERROR: Could not find insertion point")
```
