diff --git a/src/lib/server/db/schema.ts b/src/lib/server/db/schema.ts index 10ade18..c01ef60 100644 --- a/src/lib/server/db/schema.ts +++ b/src/lib/server/db/schema.ts @@ -383,6 +383,7 @@ export const parts = pgTable( name: text('name'), category: text('category').notNull(), mpn: text('mpn'), + lcscNumber: text('lcsc_number'), value: text('value'), valueNumeric: doublePrecision('value_numeric'), voltage: text('voltage'), diff --git a/src/lib/server/digikeyLookup.ts b/src/lib/server/digikeyLookup.ts index 7711851..0573cdf 100644 --- a/src/lib/server/digikeyLookup.ts +++ b/src/lib/server/digikeyLookup.ts @@ -60,6 +60,7 @@ export async function lookupDigikeyPart(pn: string): Promise { +// Scrapes LCSC's own product page for the human-readable "Key Attributes" summary. +// This reads a third-party page's internal Next.js SSR blob (not a documented API), so it may break silently — always returns null on any failure, never throws. +async function fetchKeyAttributes(code: string): Promise { + try { + const res = await fetch(`https://www.lcsc.com/product-detail/${code}.html`, { + headers: { 'User-Agent': USER_AGENT, Accept: 'text/html' }, + signal: AbortSignal.timeout(8000) + }); + if (!res.ok) return null; + + const html = await res.text(); + const match = html.match(/