@contentisking/seomcp 0.1.52 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +11 -7
- package/README.md +14 -9
- package/dist/core/ai-referrals.d.ts +87 -0
- package/dist/core/ai-referrals.js +95 -0
- package/dist/core/ai-referrals.js.map +1 -0
- package/dist/core/bing.d.ts +40 -0
- package/dist/core/bing.js +56 -0
- package/dist/core/bing.js.map +1 -1
- package/dist/core/common-crawl.d.ts +55 -0
- package/dist/core/common-crawl.js +132 -0
- package/dist/core/common-crawl.js.map +1 -0
- package/dist/core/entity.d.ts +84 -0
- package/dist/core/entity.js +244 -0
- package/dist/core/entity.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/library/domande.js +11 -0
- package/dist/library/domande.js.map +1 -1
- package/dist/library/prompt-guide.js +2 -0
- package/dist/library/prompt-guide.js.map +1 -1
- package/dist/prompts/dati.js +18 -0
- package/dist/prompts/dati.js.map +1 -1
- package/dist/prompts/geo.js +17 -0
- package/dist/prompts/geo.js.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/bing.js +48 -0
- package/dist/tools/bing.js.map +1 -1
- package/dist/tools/ga.js +53 -0
- package/dist/tools/ga.js.map +1 -1
- package/dist/tools/geo.js +25 -0
- package/dist/tools/geo.js.map +1 -1
- package/dist/tools/shared.d.ts +2 -0
- package/dist/tools/shared.js.map +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[🇮🇹 Versione italiana](README.md) · [Website](https://seomcp.contentisking.guru) · [npm](https://www.npmjs.com/package/@contentisking/seomcp) · [MIT](LICENSE) license
|
|
8
8
|
|
|
9
|
-
`seomcp` is an [MCP](https://modelcontextprotocol.io) server that lets your AI assistant (Claude, ChatGPT, GitHub Copilot, Gemini CLI, Mistral Vibe and other MCP clients) read your sites' data from Search Console, Google Analytics 4, Bing Webmaster Tools, Cloudflare, PageSpeed Insights and the Chrome UX Report, and analyze public pages: AI crawler access, structured data, redirects, canonicals, sitemaps and broken links. **
|
|
9
|
+
`seomcp` is an [MCP](https://modelcontextprotocol.io) server that lets your AI assistant (Claude, ChatGPT, GitHub Copilot, Gemini CLI, Mistral Vibe and other MCP clients) read your sites' data from Search Console, Google Analytics 4, Bing Webmaster Tools, Cloudflare, PageSpeed Insights and the Chrome UX Report, and analyze public pages: AI crawler access, structured data, redirects, canonicals, sitemaps and broken links. **34 tools and 20 prompts, all read-only.** Ask things like:
|
|
10
10
|
|
|
11
11
|
> Which queries rank in positions 4-20 over the last 90 days, and which pages should I optimize first?
|
|
12
12
|
>
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
- **Read-only.** It only requests the `webmasters.readonly` and `analytics.readonly` Google scopes and cannot change anything in your properties.
|
|
20
20
|
- **Your credentials stay on your machine.** No intermediate server, no third-party gateway, no telemetry.
|
|
21
|
-
- **Official libraries only:** the MCP SDK, `@googleapis/searchconsole`, `@googleapis/analyticsdata`, `@googleapis/analyticsadmin`, `@googleapis/pagespeedonline`, `@googleapis/chromeuxreport` and `google-auth-library`. Bing
|
|
22
|
-
- **Small, readable codebase.** About
|
|
21
|
+
- **Official libraries only:** the MCP SDK, `@googleapis/searchconsole`, `@googleapis/analyticsdata`, `@googleapis/analyticsadmin`, `@googleapis/pagespeedonline`, `@googleapis/chromeuxreport` and `google-auth-library`. Bing, Wikidata, the Knowledge Graph and Common Crawl are plain REST calls to their public APIs. HTML parsing: `htmlparser2` (the engine behind cheerio).
|
|
22
|
+
- **Small, readable codebase.** About 7,700 lines of TypeScript in [`src/`](src), easy to audit before you install it.
|
|
23
23
|
- **No misuse of the Google Indexing API**, which Google reserves for job postings and livestreams.
|
|
24
24
|
|
|
25
|
-
## Tools (
|
|
25
|
+
## Tools (34)
|
|
26
26
|
|
|
27
27
|
| Tool | What it does |
|
|
28
28
|
|---|---|
|
|
@@ -39,12 +39,15 @@
|
|
|
39
39
|
| `ga_organic_landing_pages` | Organic search landing pages: sessions, engagement, key events, revenue |
|
|
40
40
|
| `ga_compare_periods` | Period comparison on any metric: losers and gainers |
|
|
41
41
|
| `ga_realtime` | Active users in the last 30 minutes |
|
|
42
|
+
| `ga_ai_referrals` | Visits from AI assistants (ChatGPT, Perplexity, Gemini, Copilot, Claude…): per assistant, with landing pages, conversions and change vs the previous period |
|
|
42
43
|
| `crux_query` | Real-user Core Web Vitals from Chrome (LCP, INP, CLS): rating and distribution |
|
|
43
44
|
| `crux_history` | Weekly trend of real-user Core Web Vitals, up to 40 weeks |
|
|
44
45
|
| `psi_analyze` | PageSpeed Insights test: scores, metrics, opportunities and SEO audits |
|
|
45
46
|
| `geo_ai_access` | GEO: which AI crawlers can read the site (robots.txt, llms.txt, Content Signals, TDMRep) |
|
|
46
47
|
| `geo_page_metrics` | GEO/AEO: page metrics as an AI crawler sees it, plus HTTPS and domain age |
|
|
47
48
|
| `geo_page_sections` | GEO/AEO: page text split into sections, with per-section metrics |
|
|
49
|
+
| `geo_entity` | GEO: is the brand an entity on Wikidata and in Google's Knowledge Graph, linked to the site via sameAs? |
|
|
50
|
+
| `geo_common_crawl` | GEO: are the site's pages in Common Crawl, the archive many models are trained on? |
|
|
48
51
|
| `schema_validate` | schema.org validator: official vocabulary, Google rich result requirements, consistency with the page. Also on pasted JSON-LD |
|
|
49
52
|
| `tech_page_audit` | Technical page checks: redirects, TTFB, indexability, canonical, hreflang, Open Graph, images, headings, security headers |
|
|
50
53
|
| `tech_site_check` | Technical site checks: sitemap, URL sample, 404 page, broken internal links |
|
|
@@ -53,13 +56,14 @@
|
|
|
53
56
|
| `bing_page_stats` | Bing performance by page |
|
|
54
57
|
| `bing_keyword_stats` | Keyword search volume (defaults to Italy / Italian; set `country` and `language` for other markets) |
|
|
55
58
|
| `bing_inbound_links` | Inbound links according to Bing: most linked pages, referring sites, anchor texts (current snapshot) |
|
|
59
|
+
| `bing_crawl` | Crawling according to Bing: pages in the index, responses, errors and URLs with issues |
|
|
56
60
|
| `cf_traffic` | Cloudflare: real visits and page views, including visitors who reject cookies |
|
|
57
61
|
| `cf_ai_crawlers` | Cloudflare: AI crawlers that actually visit, which pages and which responses |
|
|
58
62
|
| `cf_errors` | Cloudflare: pages returning 404 or 5xx to visitors |
|
|
59
63
|
|
|
60
|
-
Plus
|
|
64
|
+
Plus 20 **prompts**, grouped by goal like Bing Webmaster Tools' prompt guide: understanding the data (traffic drops, monthly client report, traffic that doesn't convert, Google vs Bing, user questions), improving results (striking-distance queries, low-CTR titles and descriptions, keyword cannibalization, Core Web Vitals plan, editorial plan), getting cited by AI (traffic from AI assistants, does AI know who you are (entity and Common Crawl), which AI crawlers really read the site, GEO page audit, AI crawler access, competitor comparison, citable passage) and checks and fixes (technical audit, structured data, post-migration check). Inside the assistant the guide is the MCP resource `seomcp://prompt`. Details (Italian): [seomcp.contentisking.guru/prompt](https://seomcp.contentisking.guru/prompt/).
|
|
61
65
|
|
|
62
|
-
**Ready-made questions:**
|
|
66
|
+
**Ready-made questions:** 86 conversation starters in 10 themes (29 need no credentials), in [domande/](domande/README.md) (Italian) and as MCP resources inside seomcp: `seomcp://domande` (index) and `seomcp://domande/<theme>`.
|
|
63
67
|
|
|
64
68
|
## Install
|
|
65
69
|
|
|
@@ -69,7 +73,7 @@ Requires **Node.js 22+**. Configure only the sources you use.
|
|
|
69
73
|
|
|
70
74
|
Manual setup:
|
|
71
75
|
|
|
72
|
-
1. **Credentials:** see the setup guides for [Google](docs/google-setup.md), [Google Analytics](docs/google-analytics-setup.md), [PageSpeed/CrUX](docs/pagespeed-setup.md) and [Bing](docs/bing-setup.md). They are in Italian, and the steps are the same in English UIs. The [credentials page](https://seomcp.contentisking.guru/credenziali/) (Italian) has direct links to every console screen, a one-click link that enables all
|
|
76
|
+
1. **Credentials:** see the setup guides for [Google](docs/google-setup.md), [Google Analytics](docs/google-analytics-setup.md), [PageSpeed/CrUX](docs/pagespeed-setup.md) and [Bing](docs/bing-setup.md). They are in Italian, and the steps are the same in English UIs. **Cloudflare** (optional, free plan included) needs a read-only token with *Zone → Zone → Read* and *Zone → Analytics → Read*; leave the token's IP filter empty if your connection has a dynamic IP, as most home connections do. What you get and how to enable it: [Cloudflare page](https://seomcp.contentisking.guru/cloudflare/) (Italian). The [credentials page](https://seomcp.contentisking.guru/credenziali/) (Italian) has direct links to every console screen, a one-click link that enables all six Google APIs, and a generator that fills in the config for your assistant.
|
|
73
77
|
2. **Claude Code:**
|
|
74
78
|
|
|
75
79
|
```bash
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[🇬🇧 English version](README.en.md) · [Sito](https://seomcp.contentisking.guru) · [npm](https://www.npmjs.com/package/@contentisking/seomcp) · Licenza [MIT](LICENSE)
|
|
8
8
|
|
|
9
|
-
`seomcp` è un server [MCP](https://modelcontextprotocol.io) che permette al tuo assistente AI (Claude, ChatGPT, GitHub Copilot, Gemini CLI, Mistral Vibe e altri client MCP) di leggere i dati dei tuoi siti da Search Console, Google Analytics 4, Bing Webmaster Tools, Cloudflare, PageSpeed Insights e Chrome UX Report, e di analizzare le pagine pubbliche: accesso dei crawler AI, dati strutturati, redirect, canonical, sitemap e link rotti. **
|
|
9
|
+
`seomcp` è un server [MCP](https://modelcontextprotocol.io) che permette al tuo assistente AI (Claude, ChatGPT, GitHub Copilot, Gemini CLI, Mistral Vibe e altri client MCP) di leggere i dati dei tuoi siti da Search Console, Google Analytics 4, Bing Webmaster Tools, Cloudflare, PageSpeed Insights e Chrome UX Report, e di analizzare le pagine pubbliche: accesso dei crawler AI, dati strutturati, redirect, canonical, sitemap e link rotti. **34 tool e 20 prompt, tutti in sola lettura.** Così puoi chiedere, in italiano:
|
|
10
10
|
|
|
11
11
|
> Quali query sono in posizione 4-20 negli ultimi 90 giorni, e quali pagine dovrei ottimizzare per prime?
|
|
12
12
|
>
|
|
@@ -22,11 +22,11 @@ Affidare le credenziali di Search Console a uno strumento è una decisione seria
|
|
|
22
22
|
|
|
23
23
|
- **Sola lettura.** Chiede a Google solo gli scope `webmasters.readonly` e `analytics.readonly`: non può modificare nulla nelle tue proprietà.
|
|
24
24
|
- **Le credenziali restano sul tuo computer.** Nessun server intermedio, nessun gateway di terzi, nessuna telemetria.
|
|
25
|
-
- **Solo librerie ufficiali:** l'SDK MCP, `@googleapis/searchconsole`, `@googleapis/analyticsdata`, `@googleapis/analyticsadmin`, `@googleapis/pagespeedonline`, `@googleapis/chromeuxreport` e `google-auth-library`. Bing
|
|
26
|
-
- **Codice piccolo e leggibile.** Circa
|
|
25
|
+
- **Solo librerie ufficiali:** l'SDK MCP, `@googleapis/searchconsole`, `@googleapis/analyticsdata`, `@googleapis/analyticsadmin`, `@googleapis/pagespeedonline`, `@googleapis/chromeuxreport` e `google-auth-library`. Bing, Wikidata, Knowledge Graph e Common Crawl sono semplici chiamate REST alle loro API pubbliche. Per leggere l'HTML delle pagine: `htmlparser2`, la libreria usata da cheerio.
|
|
26
|
+
- **Codice piccolo e leggibile.** Circa 7.700 righe di TypeScript in [`src/`](src): leggerlo prima di installarlo è alla portata di chiunque.
|
|
27
27
|
- **Nessun uso improprio della Google Indexing API**, che Google riserva alle offerte di lavoro e alle dirette video.
|
|
28
28
|
|
|
29
|
-
## Tool disponibili (
|
|
29
|
+
## Tool disponibili (34)
|
|
30
30
|
|
|
31
31
|
| Tool | Cosa fa |
|
|
32
32
|
|---|---|
|
|
@@ -43,12 +43,15 @@ Affidare le credenziali di Search Console a uno strumento è una decisione seria
|
|
|
43
43
|
| `ga_organic_landing_pages` | Pagine di destinazione della ricerca organica: sessioni, coinvolgimento, conversioni, ricavi |
|
|
44
44
|
| `ga_compare_periods` | Confronto tra periodi su qualsiasi metrica: cali e crescite |
|
|
45
45
|
| `ga_realtime` | Utenti attivi negli ultimi 30 minuti |
|
|
46
|
+
| `ga_ai_referrals` | Visite dagli assistenti AI (ChatGPT, Perplexity, Gemini, Copilot, Claude…): per assistente, con pagine di destinazione, conversioni e confronto col periodo prima |
|
|
46
47
|
| `crux_query` | Core Web Vitals reali degli utenti Chrome (LCP, INP, CLS): giudizio e distribuzione |
|
|
47
48
|
| `crux_history` | Andamento settimanale dei Core Web Vitals reali, fino a 40 settimane |
|
|
48
49
|
| `psi_analyze` | Test PageSpeed Insights: punteggi, metriche, opportunità e controlli SEO |
|
|
49
50
|
| `geo_ai_access` | GEO: quali crawler AI possono leggere il sito (robots.txt, llms.txt, Content Signals, TDMRep) |
|
|
50
51
|
| `geo_page_metrics` | GEO/AEO: misure della pagina come la vede un crawler AI, più HTTPS ed età del dominio |
|
|
51
52
|
| `geo_page_sections` | GEO/AEO: il testo della pagina diviso in sezioni, con le misure di ciascuna |
|
|
53
|
+
| `geo_entity` | GEO: il brand è un'entità su Wikidata e nel Knowledge Graph di Google, collegata al sito con sameAs? |
|
|
54
|
+
| `geo_common_crawl` | GEO: le pagine sono in Common Crawl, l'archivio con cui si addestrano molti modelli? |
|
|
52
55
|
| `schema_validate` | Validatore schema.org: vocabolario ufficiale, requisiti Google per i risultati avanzati, coerenza con la pagina. Anche su JSON-LD incollato |
|
|
53
56
|
| `tech_page_audit` | Controlli tecnici della pagina: redirect, TTFB, indicizzabilità, canonical, hreflang, Open Graph, immagini, titoli, header di sicurezza |
|
|
54
57
|
| `tech_site_check` | Controlli tecnici del sito: sitemap, campione di URL, pagina 404, link interni rotti |
|
|
@@ -57,28 +60,29 @@ Affidare le credenziali di Search Console a uno strumento è una decisione seria
|
|
|
57
60
|
| `bing_page_stats` | Performance per pagina su Bing |
|
|
58
61
|
| `bing_keyword_stats` | Volumi di ricerca di una keyword (default Italia / italiano) |
|
|
59
62
|
| `bing_inbound_links` | Link in entrata secondo Bing: pagine più linkate, siti di provenienza, testi dei link (fotografia attuale) |
|
|
63
|
+
| `bing_crawl` | Scansione secondo Bing: pagine nell'indice, risposte, errori e URL con problemi |
|
|
60
64
|
| `cf_traffic` | Cloudflare: visite e pagine viste reali, anche di chi rifiuta i cookie |
|
|
61
65
|
| `cf_ai_crawlers` | Cloudflare: crawler AI che passano davvero, su quali pagine e con quali risposte |
|
|
62
66
|
| `cf_errors` | Cloudflare: pagine che rispondono 404 o 5xx ai visitatori |
|
|
63
67
|
|
|
64
68
|
Le analisi più complesse (cannibalizzazione, content gap, report) le fa l'assistente ragionando sui dati: non serve codificarle nel server.
|
|
65
69
|
|
|
66
|
-
### Prompt (
|
|
70
|
+
### Prompt (20)
|
|
67
71
|
|
|
68
|
-
Oltre ai tool, seomcp offre
|
|
72
|
+
Oltre ai tool, seomcp offre 20 **prompt**: analisi già impostate che combinano più tool e chiudono con le correzioni in ordine di impatto. Sono divisi per obiettivo, come la guida dei prompt di Bing Webmaster Tools:
|
|
69
73
|
|
|
70
74
|
| Obiettivo | Prompt |
|
|
71
75
|
|---|---|
|
|
72
76
|
| **Capire i dati** | Perché sto perdendo traffico? · Report mensile per il cliente · Traffico che non converte · Google e Bing a confronto · Rispondo alle domande dei miei utenti? |
|
|
73
77
|
| **Migliorare i risultati** | Opportunità a distanza di tiro · Title e description che non convincono · Pagine in concorrenza tra loro · Piano per i Core Web Vitals · Piano editoriale per le risposte AI |
|
|
74
|
-
| **Farsi citare dalle AI** | Quali AI leggono davvero il mio sito? · Audit GEO della pagina · Il mio sito è aperto alle AI? · Perché citano loro e non me? · Rendi citabile questo passaggio |
|
|
78
|
+
| **Farsi citare dalle AI** | Quanto traffico mi portano le AI? · Le AI sanno chi sono? · Quali AI leggono davvero il mio sito? · Audit GEO della pagina · Il mio sito è aperto alle AI? · Perché citano loro e non me? · Rendi citabile questo passaggio |
|
|
75
79
|
| **Controlli e correzioni** | Audit tecnico del sito · Correggi i miei dati strutturati · Controllo dopo una migrazione |
|
|
76
80
|
|
|
77
81
|
Dentro l'assistente la stessa guida è la risorsa MCP `seomcp://prompt`. Dettagli, argomenti e credenziali di ogni prompt: [seomcp.contentisking.guru/prompt](https://seomcp.contentisking.guru/prompt/). Approfondimenti: [docs/geo.md](docs/geo.md) e [docs/schema-validator.md](docs/schema-validator.md).
|
|
78
82
|
|
|
79
|
-
### Domande pronte (
|
|
83
|
+
### Domande pronte (86)
|
|
80
84
|
|
|
81
|
-
Non sai da dove partire? L'archivio [domande/](domande/README.md) raccoglie
|
|
85
|
+
Non sai da dove partire? L'archivio [domande/](domande/README.md) raccoglie 86 domande da copiare nell'assistente, divise in 10 temi: primi passi, traffico, opportunità, indicizzazione, GEO e AEO, dati strutturati, prestazioni, Analytics, Bing e report. Per ognuna c'è cosa serve (29 funzionano senza credenziali), quali tool usa e cosa aspettarsi.
|
|
82
86
|
|
|
83
87
|
Le stesse domande sono anche **risorse MCP** dentro seomcp: `seomcp://domande` è l'indice e `seomcp://domande/<tema>` contiene il singolo tema. Nei client che supportano le risorse si allegano alla chat; in Claude Code si richiamano con `@`. Oppure chiedi all'assistente: «Cosa posso chiedere a seomcp?».
|
|
84
88
|
|
|
@@ -104,6 +108,7 @@ La pagina [Credenziali](https://seomcp.contentisking.guru/credenziali/) ha tutti
|
|
|
104
108
|
- **Google Analytics 4** (facoltativo): stesse credenziali di Search Console, più tre passaggi nella [guida Analytics](docs/google-analytics-setup.md).
|
|
105
109
|
- **PageSpeed e Core Web Vitals** (facoltativo): una API key gratuita, come spiegato nella [guida PageSpeed](docs/pagespeed-setup.md).
|
|
106
110
|
- **Bing Webmaster Tools:** genera una API key in due minuti, come spiegato nella [guida](docs/bing-setup.md).
|
|
111
|
+
- **Cloudflare** (facoltativo, se il sito passa da Cloudflare, anche con il piano gratuito): un token in sola lettura con i permessi *Zona → Zona → Lettura* e *Zona → Analisi → Lettura*. Il filtro IP del token è facoltativo: con una connessione domestica, che ha l'IP dinamico, lascialo vuoto. Cosa ottieni e come attivarlo nella [pagina Cloudflare](https://seomcp.contentisking.guru/cloudflare/).
|
|
107
112
|
|
|
108
113
|
### 2. Collegalo al tuo assistente
|
|
109
114
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { GaRow } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Assistenti AI che portano visite al sito, riconosciuti dalla sorgente della sessione in GA4
|
|
4
|
+
* (dominio del referrer o utm_source, es. ChatGPT aggiunge utm_source=chatgpt.com ai link).
|
|
5
|
+
*/
|
|
6
|
+
export declare const AI_ASSISTANTS: readonly [{
|
|
7
|
+
readonly assistant: 'ChatGPT';
|
|
8
|
+
readonly vendor: 'OpenAI';
|
|
9
|
+
readonly domains: readonly ['chatgpt.com', 'openai.com'];
|
|
10
|
+
}, {
|
|
11
|
+
readonly assistant: 'Perplexity';
|
|
12
|
+
readonly vendor: 'Perplexity';
|
|
13
|
+
readonly domains: readonly ['perplexity.ai'];
|
|
14
|
+
}, {
|
|
15
|
+
readonly assistant: 'Gemini';
|
|
16
|
+
readonly vendor: 'Google';
|
|
17
|
+
readonly domains: readonly ['gemini.google.com', 'bard.google.com'];
|
|
18
|
+
}, {
|
|
19
|
+
readonly assistant: 'Copilot';
|
|
20
|
+
readonly vendor: 'Microsoft';
|
|
21
|
+
readonly domains: readonly ['copilot.microsoft.com', 'copilot.cloud.microsoft'];
|
|
22
|
+
}, {
|
|
23
|
+
readonly assistant: 'Claude';
|
|
24
|
+
readonly vendor: 'Anthropic';
|
|
25
|
+
readonly domains: readonly ['claude.ai'];
|
|
26
|
+
}, {
|
|
27
|
+
readonly assistant: 'Le Chat';
|
|
28
|
+
readonly vendor: 'Mistral AI';
|
|
29
|
+
readonly domains: readonly ['chat.mistral.ai'];
|
|
30
|
+
}, {
|
|
31
|
+
readonly assistant: 'DeepSeek';
|
|
32
|
+
readonly vendor: 'DeepSeek';
|
|
33
|
+
readonly domains: readonly ['deepseek.com'];
|
|
34
|
+
}, {
|
|
35
|
+
readonly assistant: 'Grok';
|
|
36
|
+
readonly vendor: 'xAI';
|
|
37
|
+
readonly domains: readonly ['grok.com'];
|
|
38
|
+
}, {
|
|
39
|
+
readonly assistant: 'Meta AI';
|
|
40
|
+
readonly vendor: 'Meta';
|
|
41
|
+
readonly domains: readonly ['meta.ai'];
|
|
42
|
+
}, {
|
|
43
|
+
readonly assistant: 'Duck.ai';
|
|
44
|
+
readonly vendor: 'DuckDuckGo';
|
|
45
|
+
readonly domains: readonly ['duck.ai'];
|
|
46
|
+
}, {
|
|
47
|
+
readonly assistant: 'You.com';
|
|
48
|
+
readonly vendor: 'You.com';
|
|
49
|
+
readonly domains: readonly ['you.com'];
|
|
50
|
+
}, {
|
|
51
|
+
readonly assistant: 'Phind';
|
|
52
|
+
readonly vendor: 'Phind';
|
|
53
|
+
readonly domains: readonly ['phind.com'];
|
|
54
|
+
}, {
|
|
55
|
+
readonly assistant: 'Poe';
|
|
56
|
+
readonly vendor: 'Quora';
|
|
57
|
+
readonly domains: readonly ['poe.com'];
|
|
58
|
+
}];
|
|
59
|
+
export type AiAssistant = (typeof AI_ASSISTANTS)[number];
|
|
60
|
+
/** Assistente a cui appartiene una sorgente GA4 ("chatgpt.com", "www.perplexity.ai"…), se è uno di quelli noti. */
|
|
61
|
+
export declare function aiAssistantOf(source: string): AiAssistant | undefined;
|
|
62
|
+
/** Espressione regolare (RE2, per i filtri GA4) che seleziona le sorgenti degli assistenti AI. */
|
|
63
|
+
export declare function aiSourceRegex(): string;
|
|
64
|
+
export interface AiReferralSummary {
|
|
65
|
+
assistant: string;
|
|
66
|
+
vendor: string;
|
|
67
|
+
sessions: number;
|
|
68
|
+
previousSessions?: number;
|
|
69
|
+
/** Variazione percentuale rispetto al periodo precedente (null se prima era zero). */
|
|
70
|
+
change?: number | null;
|
|
71
|
+
engagedSessions: number;
|
|
72
|
+
engagementRate: number;
|
|
73
|
+
keyEvents: number;
|
|
74
|
+
revenue: number;
|
|
75
|
+
/** Sorgenti GA4 che compongono il totale, es. "chatgpt.com". */
|
|
76
|
+
sources: string[];
|
|
77
|
+
topLandingPages: Array<{
|
|
78
|
+
page: string;
|
|
79
|
+
sessions: number;
|
|
80
|
+
keyEvents: number;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Raggruppa per assistente le righe GA4 con dimensioni sessionSource e landingPage
|
|
85
|
+
* (metriche sessions, engagedSessions, keyEvents, totalRevenue). Le sorgenti non riconosciute sono scartate.
|
|
86
|
+
*/
|
|
87
|
+
export declare function aggregateAiReferrals(rows: GaRow[], previous?: GaRow[], pagesPerAssistant?: number): AiReferralSummary[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assistenti AI che portano visite al sito, riconosciuti dalla sorgente della sessione in GA4
|
|
3
|
+
* (dominio del referrer o utm_source, es. ChatGPT aggiunge utm_source=chatgpt.com ai link).
|
|
4
|
+
*/
|
|
5
|
+
export const AI_ASSISTANTS = [
|
|
6
|
+
{ assistant: 'ChatGPT', vendor: 'OpenAI', domains: ['chatgpt.com', 'openai.com'] },
|
|
7
|
+
{ assistant: 'Perplexity', vendor: 'Perplexity', domains: ['perplexity.ai'] },
|
|
8
|
+
{ assistant: 'Gemini', vendor: 'Google', domains: ['gemini.google.com', 'bard.google.com'] },
|
|
9
|
+
{ assistant: 'Copilot', vendor: 'Microsoft', domains: ['copilot.microsoft.com', 'copilot.cloud.microsoft'] },
|
|
10
|
+
{ assistant: 'Claude', vendor: 'Anthropic', domains: ['claude.ai'] },
|
|
11
|
+
{ assistant: 'Le Chat', vendor: 'Mistral AI', domains: ['chat.mistral.ai'] },
|
|
12
|
+
{ assistant: 'DeepSeek', vendor: 'DeepSeek', domains: ['deepseek.com'] },
|
|
13
|
+
{ assistant: 'Grok', vendor: 'xAI', domains: ['grok.com'] },
|
|
14
|
+
{ assistant: 'Meta AI', vendor: 'Meta', domains: ['meta.ai'] },
|
|
15
|
+
{ assistant: 'Duck.ai', vendor: 'DuckDuckGo', domains: ['duck.ai'] },
|
|
16
|
+
{ assistant: 'You.com', vendor: 'You.com', domains: ['you.com'] },
|
|
17
|
+
{ assistant: 'Phind', vendor: 'Phind', domains: ['phind.com'] },
|
|
18
|
+
{ assistant: 'Poe', vendor: 'Quora', domains: ['poe.com'] },
|
|
19
|
+
];
|
|
20
|
+
/** Assistente a cui appartiene una sorgente GA4 ("chatgpt.com", "www.perplexity.ai"…), se è uno di quelli noti. */
|
|
21
|
+
export function aiAssistantOf(source) {
|
|
22
|
+
const host = source.trim().toLowerCase().replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace(/^www\./, '');
|
|
23
|
+
if (!host)
|
|
24
|
+
return undefined;
|
|
25
|
+
return AI_ASSISTANTS.find((a) => a.domains.some((d) => host === d || host.endsWith(`.${d}`)));
|
|
26
|
+
}
|
|
27
|
+
/** Espressione regolare (RE2, per i filtri GA4) che seleziona le sorgenti degli assistenti AI. */
|
|
28
|
+
export function aiSourceRegex() {
|
|
29
|
+
const domains = AI_ASSISTANTS.flatMap((a) => a.domains).map((d) => d.replace(/\./g, '\\.'));
|
|
30
|
+
return `(^|\\.)(${domains.join('|')})$`;
|
|
31
|
+
}
|
|
32
|
+
const round = (n, d = 4) => Math.round(n * 10 ** d) / 10 ** d;
|
|
33
|
+
/**
|
|
34
|
+
* Raggruppa per assistente le righe GA4 con dimensioni sessionSource e landingPage
|
|
35
|
+
* (metriche sessions, engagedSessions, keyEvents, totalRevenue). Le sorgenti non riconosciute sono scartate.
|
|
36
|
+
*/
|
|
37
|
+
export function aggregateAiReferrals(rows, previous = [], pagesPerAssistant = 10) {
|
|
38
|
+
const by = new Map();
|
|
39
|
+
for (const r of rows) {
|
|
40
|
+
const source = r.dimensions.sessionSource ?? '';
|
|
41
|
+
const a = aiAssistantOf(source);
|
|
42
|
+
if (!a)
|
|
43
|
+
continue;
|
|
44
|
+
const e = by.get(a.assistant) ?? { a, sessions: 0, engaged: 0, keyEvents: 0, revenue: 0, sources: new Set(), pages: new Map() };
|
|
45
|
+
const sessions = r.metrics.sessions ?? 0;
|
|
46
|
+
const keyEvents = r.metrics.keyEvents ?? 0;
|
|
47
|
+
e.sessions += sessions;
|
|
48
|
+
e.engaged += r.metrics.engagedSessions ?? 0;
|
|
49
|
+
e.keyEvents += keyEvents;
|
|
50
|
+
e.revenue += r.metrics.totalRevenue ?? 0;
|
|
51
|
+
e.sources.add(source);
|
|
52
|
+
const page = r.dimensions.landingPage ?? '';
|
|
53
|
+
const p = e.pages.get(page) ?? { sessions: 0, keyEvents: 0 };
|
|
54
|
+
p.sessions += sessions;
|
|
55
|
+
p.keyEvents += keyEvents;
|
|
56
|
+
e.pages.set(page, p);
|
|
57
|
+
by.set(a.assistant, e);
|
|
58
|
+
}
|
|
59
|
+
const prev = new Map();
|
|
60
|
+
for (const r of previous) {
|
|
61
|
+
const a = aiAssistantOf(r.dimensions.sessionSource ?? '');
|
|
62
|
+
if (a)
|
|
63
|
+
prev.set(a.assistant, (prev.get(a.assistant) ?? 0) + (r.metrics.sessions ?? 0));
|
|
64
|
+
}
|
|
65
|
+
const withPrevious = previous.length > 0;
|
|
66
|
+
const out = [...by.values()].map((e) => {
|
|
67
|
+
const before = prev.get(e.a.assistant) ?? 0;
|
|
68
|
+
return {
|
|
69
|
+
assistant: e.a.assistant,
|
|
70
|
+
vendor: e.a.vendor,
|
|
71
|
+
sessions: e.sessions,
|
|
72
|
+
...(withPrevious ? { previousSessions: before, change: before ? round(((e.sessions - before) / before) * 100, 1) : null } : {}),
|
|
73
|
+
engagedSessions: e.engaged,
|
|
74
|
+
engagementRate: e.sessions ? round(e.engaged / e.sessions) : 0,
|
|
75
|
+
keyEvents: e.keyEvents,
|
|
76
|
+
revenue: round(e.revenue, 2),
|
|
77
|
+
sources: [...e.sources].sort(),
|
|
78
|
+
topLandingPages: [...e.pages.entries()]
|
|
79
|
+
.sort((x, y) => y[1].sessions - x[1].sessions)
|
|
80
|
+
.slice(0, pagesPerAssistant)
|
|
81
|
+
.map(([page, v]) => ({ page, ...v })),
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
// Assistenti che portavano visite prima e ora no: restano visibili con zero sessioni.
|
|
85
|
+
if (withPrevious) {
|
|
86
|
+
for (const [assistant, before] of prev) {
|
|
87
|
+
if (by.has(assistant) || !before)
|
|
88
|
+
continue;
|
|
89
|
+
const a = AI_ASSISTANTS.find((x) => x.assistant === assistant);
|
|
90
|
+
out.push({ assistant, vendor: a.vendor, sessions: 0, previousSessions: before, change: -100, engagedSessions: 0, engagementRate: 0, keyEvents: 0, revenue: 0, sources: [], topLandingPages: [] });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out.sort((x, y) => y.sessions - x.sessions || (y.previousSessions ?? 0) - (x.previousSessions ?? 0));
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=ai-referrals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-referrals.js","sourceRoot":"","sources":["../../src/core/ai-referrals.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE;IAClF,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE;IAC7E,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,EAAE;IAC5F,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,EAAE;IAC5G,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE;IACpE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,iBAAiB,CAAC,EAAE;IAC5E,EAAE,SAAS,EAAE,UAAU,EAAE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ufficiale.
|
|
52
52
|
*/
|
|
53
53
|
getUrlLinks(siteUrl: string, link: string, maxPages?: number): Promise<BingLinkDetail[]>;
|
|
54
|
+
/** Statistiche di scansione giorno per giorno, ultimi 6 mesi circa (GetCrawlStats). */
|
|
55
|
+
getCrawlStats(siteUrl: string): Promise<BingCrawlStats[]>;
|
|
56
|
+
/** URL con problemi di scansione (GetCrawlIssues). Le correzioni spariscono dall'elenco dopo qualche giorno. */
|
|
57
|
+
getCrawlIssues(siteUrl: string): Promise<BingCrawlIssue[]>;
|
|
54
58
|
private get;
|
|
55
59
|
}
|
|
60
|
+
export interface BingCrawlStats {
|
|
61
|
+
date: string;
|
|
62
|
+
crawledPages: number;
|
|
63
|
+
crawlErrors: number;
|
|
64
|
+
inIndex: number;
|
|
65
|
+
inLinks: number;
|
|
66
|
+
code2xx: number;
|
|
67
|
+
code301: number;
|
|
68
|
+
code302: number;
|
|
69
|
+
code4xx: number;
|
|
70
|
+
code5xx: number;
|
|
71
|
+
allOtherCodes: number;
|
|
72
|
+
blockedByRobotsTxt: number;
|
|
73
|
+
containsMalware: number;
|
|
74
|
+
}
|
|
75
|
+
export interface BingCrawlIssue {
|
|
76
|
+
url: string;
|
|
77
|
+
httpCode: number;
|
|
78
|
+
issues: BingCrawlIssueType[];
|
|
79
|
+
inLinks: number;
|
|
80
|
+
}
|
|
81
|
+
/** Valori dell'enum a bit UrlWithCrawlIssues.CrawlIssues della Bing Webmaster API. */
|
|
82
|
+
export declare const BING_CRAWL_ISSUES: {
|
|
83
|
+
readonly Code301: 1;
|
|
84
|
+
readonly Code302: 2;
|
|
85
|
+
readonly Code4xx: 4;
|
|
86
|
+
readonly Code5xx: 8;
|
|
87
|
+
readonly BlockedByRobotsTxt: 16;
|
|
88
|
+
readonly ContainsMalware: 32;
|
|
89
|
+
readonly ImportantUrlBlockedByRobotsTxt: 64;
|
|
90
|
+
readonly DnsErrors: 128;
|
|
91
|
+
readonly TimeOutErrors: 256;
|
|
92
|
+
};
|
|
93
|
+
export type BingCrawlIssueType = keyof typeof BING_CRAWL_ISSUES;
|
|
94
|
+
/** Il campo Issues arriva come numero (somma di bit) nel JSON, o come nomi separati da spazi/virgole nell'XML. */
|
|
95
|
+
export declare function decodeCrawlIssues(value: number | string | undefined | null): BingCrawlIssueType[];
|
|
56
96
|
/** Bing restituisce le date nel formato WCF: "/Date(1727654400000-0700)/". */
|
|
57
97
|
export declare function parseBingDate(value: string): string;
|
package/dist/core/bing.js
CHANGED
|
@@ -91,6 +91,37 @@ export class BingClient {
|
|
|
91
91
|
}
|
|
92
92
|
return details;
|
|
93
93
|
}
|
|
94
|
+
/** Statistiche di scansione giorno per giorno, ultimi 6 mesi circa (GetCrawlStats). */
|
|
95
|
+
async getCrawlStats(siteUrl) {
|
|
96
|
+
const data = await this.get('GetCrawlStats', { siteUrl });
|
|
97
|
+
return (data ?? [])
|
|
98
|
+
.map((r) => ({
|
|
99
|
+
date: parseBingDate(r.Date),
|
|
100
|
+
crawledPages: r.CrawledPages ?? 0,
|
|
101
|
+
crawlErrors: r.CrawlErrors ?? 0,
|
|
102
|
+
inIndex: r.InIndex ?? 0,
|
|
103
|
+
inLinks: r.InLinks ?? 0,
|
|
104
|
+
code2xx: r.Code2xx ?? 0,
|
|
105
|
+
code301: r.Code301 ?? 0,
|
|
106
|
+
code302: r.Code302 ?? 0,
|
|
107
|
+
code4xx: r.Code4xx ?? 0,
|
|
108
|
+
code5xx: r.Code5xx ?? 0,
|
|
109
|
+
allOtherCodes: r.AllOtherCodes ?? 0,
|
|
110
|
+
blockedByRobotsTxt: r.BlockedByRobotsTxt ?? 0,
|
|
111
|
+
containsMalware: r.ContainsMalware ?? 0,
|
|
112
|
+
}))
|
|
113
|
+
.sort((a, b) => a.date.localeCompare(b.date));
|
|
114
|
+
}
|
|
115
|
+
/** URL con problemi di scansione (GetCrawlIssues). Le correzioni spariscono dall'elenco dopo qualche giorno. */
|
|
116
|
+
async getCrawlIssues(siteUrl) {
|
|
117
|
+
const data = await this.get('GetCrawlIssues', { siteUrl });
|
|
118
|
+
return (data ?? []).map((r) => ({
|
|
119
|
+
url: r.Url,
|
|
120
|
+
httpCode: r.HttpCode ?? 0,
|
|
121
|
+
issues: decodeCrawlIssues(r.Issues),
|
|
122
|
+
inLinks: r.InLinks ?? 0,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
94
125
|
async get(method, params) {
|
|
95
126
|
const url = new URL(`${this.baseUrl}/${method}`);
|
|
96
127
|
for (const [k, v] of Object.entries(params))
|
|
@@ -121,6 +152,31 @@ export class BingClient {
|
|
|
121
152
|
return body?.d;
|
|
122
153
|
}
|
|
123
154
|
}
|
|
155
|
+
/** Valori dell'enum a bit UrlWithCrawlIssues.CrawlIssues della Bing Webmaster API. */
|
|
156
|
+
export const BING_CRAWL_ISSUES = {
|
|
157
|
+
Code301: 1,
|
|
158
|
+
Code302: 2,
|
|
159
|
+
Code4xx: 4,
|
|
160
|
+
Code5xx: 8,
|
|
161
|
+
BlockedByRobotsTxt: 16,
|
|
162
|
+
ContainsMalware: 32,
|
|
163
|
+
ImportantUrlBlockedByRobotsTxt: 64,
|
|
164
|
+
DnsErrors: 128,
|
|
165
|
+
TimeOutErrors: 256,
|
|
166
|
+
};
|
|
167
|
+
/** Il campo Issues arriva come numero (somma di bit) nel JSON, o come nomi separati da spazi/virgole nell'XML. */
|
|
168
|
+
export function decodeCrawlIssues(value) {
|
|
169
|
+
const names = Object.keys(BING_CRAWL_ISSUES);
|
|
170
|
+
if (typeof value === 'number')
|
|
171
|
+
return names.filter((n) => (value & BING_CRAWL_ISSUES[n]) !== 0);
|
|
172
|
+
if (typeof value === 'string') {
|
|
173
|
+
if (/^\d+$/.test(value.trim()))
|
|
174
|
+
return decodeCrawlIssues(Number(value));
|
|
175
|
+
const parts = value.split(/[\s,]+/);
|
|
176
|
+
return names.filter((n) => parts.includes(n));
|
|
177
|
+
}
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
124
180
|
function mapStats(r) {
|
|
125
181
|
return {
|
|
126
182
|
key: r.Query,
|
package/dist/core/bing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bing.js","sourceRoot":"","sources":["../../src/core/bing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAe1C,MAAM,CAAC,MAAM,aAAa,GAAG,6CAA6C,CAAC;AAU3E;;;GAGG;AACH,MAAM,OAAO,UAAU;IACJ,MAAM,CAAS;IACf,OAAO,CAAe;IACtB,OAAO,CAAS;IAChB,SAAS,CAAS;IAEnC,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,qCAAqC,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAY,cAAc,EAAE,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,+EAA+E;IAC/E,KAAK,CAAC,aAAa,CAAC,OAAe;QACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAa,eAAe,EAAE,EAAE,OAAO,EAAE,C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AiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACxE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA8CD,SAAS,QAAQ,CAAC,CAAW;IAC3B,OAAO;QACL,GAAG,EAAE,CAAC,CAAC,KAAK;QACZ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,CAAC;QAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;QACrB,qBAAqB,EAAE,CAAC,CAAC,qBAAqB,IAAI,CAAC;QACnD,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,KAAK,GAAG,iCAAiC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Il sito è in Common Crawl? È l'archivio pubblico del web usato per addestrare molti modelli linguistici:
|
|
3
|
+
* esserci (o no) dice se le pagine possono essere finite nei dati di addestramento.
|
|
4
|
+
* Si interroga l'indice CDX pubblico (https://index.commoncrawl.org), senza credenziali.
|
|
5
|
+
* L'indice è spesso lento o sovraccarico: ogni crawl ha il suo esito e un errore non blocca gli altri.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CC_INDEX = "https://index.commoncrawl.org";
|
|
8
|
+
export interface CommonCrawlOptions {
|
|
9
|
+
userAgent?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CrawlInfo {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
cdxApi: string;
|
|
17
|
+
from?: string;
|
|
18
|
+
to?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CrawlPresence {
|
|
21
|
+
crawl: string;
|
|
22
|
+
name: string;
|
|
23
|
+
/** URL distinti trovati (fino al limite richiesto). */
|
|
24
|
+
pages: number;
|
|
25
|
+
/** true se il limite è stato raggiunto: le pagine sono almeno `pages`. */
|
|
26
|
+
truncated: boolean;
|
|
27
|
+
homepage: boolean;
|
|
28
|
+
statuses: Record<string, number>;
|
|
29
|
+
samplePages: string[];
|
|
30
|
+
firstCapture?: string;
|
|
31
|
+
lastCapture?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
interface CdxRow {
|
|
35
|
+
url?: string;
|
|
36
|
+
status?: string;
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
mime?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Elenco dei crawl, dal più recente (collinfo.json). */
|
|
41
|
+
export declare function listCrawls(opts?: CommonCrawlOptions): Promise<CrawlInfo[]>;
|
|
42
|
+
/** Presenza del dominio (sottodomini compresi) in un crawl. */
|
|
43
|
+
export declare function crawlPresence(crawl: CrawlInfo, site: string, limit: number, opts?: CommonCrawlOptions): Promise<CrawlPresence>;
|
|
44
|
+
/** Le righe CDX in formato JSON sono un oggetto per riga. */
|
|
45
|
+
export declare function parseCdx(text: string): CdxRow[];
|
|
46
|
+
export declare function summarize(rows: CdxRow[], host: string, limit: number): Omit<CrawlPresence, 'crawl' | 'name' | 'error'>;
|
|
47
|
+
/** "20260904131603" → "2026-09-04". */
|
|
48
|
+
export declare function cdxDate(ts: string): string;
|
|
49
|
+
export declare function commonCrawlPresence(site: string, crawls: number, limit: number, opts?: CommonCrawlOptions): Promise<{
|
|
50
|
+
site: string;
|
|
51
|
+
crawls: CrawlPresence[];
|
|
52
|
+
presentInLatest: boolean | null;
|
|
53
|
+
note: string;
|
|
54
|
+
}>;
|
|
55
|
+
export {};
|