From 81cc653ee73d0f4c71eee9eb48caf848c9871b3a Mon Sep 17 00:00:00 2001 From: Peter Kleiweg Date: Sat, 23 May 2026 13:50:14 +0200 Subject: [PATCH] Parool: dubbele
--- Parool/cmd/parool/parool.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Parool/cmd/parool/parool.go b/Parool/cmd/parool/parool.go index 536a7ff..c53b558 100644 --- a/Parool/cmd/parool/parool.go +++ b/Parool/cmd/parool/parool.go @@ -189,8 +189,30 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool return true } + headers, err := article.Search(`//header`) + p(err) + if len(headers) == 0 { + _ = w(fmt.Errorf("no header: %s", url)) + + fp, err := os.Create(filename + ".err") + p(err) + p(fmt.Fprintf(fp, "no elements: %s\n", url)) + p(fp.Close()) + p(os.Chtimes(filename+".err", timestamp, timestamp)) + + fp, err = os.Create(filename + ".html") + p(err) + p(fp.Write(body)) + p(fp.Close()) + p(os.Chtimes(filename+".html", timestamp, timestamp)) + + return false + + } + header := headers[0] + tags := make([]string, 0) - ell, err := article.Search(`//header//*[@data-test-id="article-label"]`) + ell, err := header.Search(`//*[@data-test-id="article-label"]`) p(err) if len(ell) == 0 { _ = w(fmt.Errorf("no labels: %s", url)) @@ -204,7 +226,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool pars := make([]string, 0) - ell, err = article.Search(`//header//*[@data-test-id="article-title"]`) + ell, err = header.Search(`//*[@data-test-id="article-title"]`) p(err) if len(ell) != 1 { _ = w(fmt.Errorf("found %d titles: %s", len(ell), url)) @@ -217,7 +239,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool } found := false - ell, err = article.Search(`//header//*[@data-test-id="header-intro"]`) + ell, err = header.Search(`//*[@data-test-id="header-intro"]`) p(err) for _, el := range ell { s := strings.TrimSpace(el.Content())