From 1738b75b2ff58f7e9324b014e504a96c604e02a0 Mon Sep 17 00:00:00 2001 From: CSiCoAlm Date: Tue, 26 Oct 2021 18:01:11 +0200 Subject: [PATCH] - Autocommit - 2021/10/26 18:01:11 --- Doc/A69WD.org | 9 +++++++++ Src/A69WD/Form1.Designer.cs | 2 +- Src/A69WD/Form1.cs | 15 +++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 Doc/A69WD.org diff --git a/Doc/A69WD.org b/Doc/A69WD.org new file mode 100644 index 0000000..23f497b --- /dev/null +++ b/Doc/A69WD.org @@ -0,0 +1,9 @@ +#+SETUPFILE: ~/.MyCfg/emacs/templates/org-html-themes/theme-readtheorg-local.setup +#+TITLE: Web Scraper per A69 +#+DESCRIPTION: Diario di bordo dell'applicazione per ricavare i racconti dal sito A69 +#+KEYWORDS: ATDB, ATWD + + +* TODO Inserire nello stato i conteggio dei link +* TODO Inserire il conto dei link anche sul nome del file o fare report +Inserire sul nome dei file, oltre alla data anche il numero di link che contengono, oppure fare un report che riassuma quanto fatto e che torna utile per confrontare due download diversi ecc... diff --git a/Src/A69WD/Form1.Designer.cs b/Src/A69WD/Form1.Designer.cs index b37379d..046104b 100644 --- a/Src/A69WD/Form1.Designer.cs +++ b/Src/A69WD/Form1.Designer.cs @@ -114,7 +114,7 @@ this.tbPath.Name = "tbPath"; this.tbPath.Size = new System.Drawing.Size(344, 20); this.tbPath.TabIndex = 7; - this.tbPath.Text = "C:\\_Autodelete\\"; + this.tbPath.Text = "C:\\Temporary\\A69WD\\Dst\\"; this.tbPath.TextChanged += new System.EventHandler(this.tbPath_TextChanged); // // btbPath diff --git a/Src/A69WD/Form1.cs b/Src/A69WD/Form1.cs index 612c960..aa139a1 100644 --- a/Src/A69WD/Form1.cs +++ b/Src/A69WD/Form1.cs @@ -51,7 +51,7 @@ namespace A69WD { get { if (string.IsNullOrEmpty(dstRac)) { // creo path e verifico l'esistenza - dstRac = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Indici"); + dstRac = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Testi"); if (!Directory.Exists(dstRac)) Directory.CreateDirectory(dstRac); } return dstRac; @@ -92,7 +92,7 @@ namespace A69WD { DownRac = false; - lblST.Text = "Inizio lo scrap dei link dei racconti"; + UpdateST("Inizio lo scrap dei link dei racconti"); if ((toDownload.Count > 0) && (cnt < MAXLINK)) { // proseguo con il download: string lk = toDownload.First(); @@ -109,7 +109,7 @@ namespace A69WD { DownRac = true; - lblST.Text = "Inizio lo scrap dei link dei racconti"; + UpdateST("Inizio lo scrap dei link dei racconti"); if ((toDownload.Count > 0) && (cnt < MAXLINK)) { // proseguo con il download: string lk = toDownload.First(); @@ -149,13 +149,14 @@ namespace A69WD { string link = wb.Url.ToString(); // aggiorno UI - lblST.Text = wb.Name + " - Donwloaded: " + link; + UpdateST(wb.Name + " - Donwloaded: " + link); // Se pagina รจ un racconto, lo salvo if (IsRacLink(link)) { sb = new StringBuilder(); sb.Append(wb.DocumentText); - cTools.WriteTextFile(Path.Combine(dstRac, GetFileName(link)), sb); + string fn = Path.Combine(DstRac, GetFileName(link)); + cTools.WriteTextFile(fn, sb); } // Registro che ho eseguito il download del link @@ -237,7 +238,7 @@ namespace A69WD { cTools.WriteTextFile(Path.Combine(DstIdx, string.Format("_A69_RacLinks_{0}.tes", dt)), sb); // avviso utente: - lblST.Text = string.Format("Finito il download in {0}", DateTime.Now - dtStartTime); + UpdateST(string.Format("Finito il download in {0}", DateTime.Now - dtStartTime)); // Riattivo UI: btnDownloadLink.Enabled = true; @@ -249,6 +250,8 @@ namespace A69WD { + + private void UpdateST(string Msg) { lblST.Text = string.Format("{0} - {1} - {2}", DateTime.Now.ToString("HH:mm:ss"), cnt.ToString("0000"), Msg); } private string GetFileName(string url) { return url.Replace("https://www.annunci69.it/racconti-erotici/", "A69_").Replace("/", "_").Replace(":", "_").Replace(@"\", "_"); } private bool IsIdxLink(string link) { return link.StartsWith(BASE_LINK_IDX); } private bool IsRacLink(string link) { foreach (string tip in Tipologie) { if (link.StartsWith(BASE_LINK_RAC + tip + "/")) return true; } return false; }