fix(news): unwrap CDATA titles at ingest and on /api/news
Excelsior rows store the feed's CDATA wrapper as the title text, including the surrounding whitespace. Strip a whole-title wrapper before insert and again on GET /api/news so existing rows read clean without an UPDATE. Plain titles and real HTML are unchanged.
This commit is contained in:
parent
02a9a5626b
commit
13a4049137
6 changed files with 154 additions and 1 deletions
|
|
@ -9,6 +9,8 @@ import psycopg2
|
|||
import os
|
||||
from scrapy.exceptions import DropItem
|
||||
|
||||
from newsScraper.feed_util import unwrap_cdata_title
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Feed items dated further ahead than this are event listings (or clock skew
|
||||
|
|
@ -104,6 +106,7 @@ class PostgresPipeline:
|
|||
if url in self.seen_urls:
|
||||
raise DropItem(f"Duplicate URL (in-memory): {url}")
|
||||
self.seen_urls.add(url)
|
||||
item['title'] = unwrap_cdata_title(item['title'])
|
||||
try:
|
||||
self.cur.execute("""
|
||||
INSERT INTO articles (title, url, content, domain, timestamp)
|
||||
|
|
|
|||
Loading…
Reference in a new issue