This commit fixes the currently broken press releases.
Some selectors got updated, some code moved around and some
cleanup for the content html.
This has also some small code changes for selectors.go,
as the configuration for the next page was not loaded before.
---
confs/koblenz-press-releases.lua | 34 ++++++++++++++++----------------selectors.go | 3 +++
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/confs/koblenz-press-releases.lua b/confs/koblenz-press-releases.lua
index d144ed9..73d23f6 100644
--- a/confs/koblenz-press-releases.lua+++ b/confs/koblenz-press-releases.lua
@@ -30,40 +30,40 @@ ratt.add(
"https://www.koblenz.de/pressezentrale"):gsub(
"https:\\/\\/www.koblenz.dehttps:\\/\\/www.koblenz.de",
"https://www.koblenz.de"
- )- return content- end,+ ):gsub(+ "<h2.*</h2>",+ ""+ ):gsub(+ "<p[^>]+>",+ "<p>"+ )+ return content+ end, link = "a",
linkattr = "href",
created = function(sel, _)
local time = sel:find("time"):first():text()
-- return current date, if the time field contains time instead of date
if time:match(".*:.*") then
- print(os.date("%d.%m.%Y"))- return+ return os.date("%d.%m.%Y") end
return time
end,
createdformat = "02.01.2006",
- description = "div.article-teaser__teaser p",+ description = "p.article-teaser__teaser", image = function(sel, _)
local img = sel:find("img"):first():attr("data-src")
if img ~= "" then
-- prepend host if needed
- if not (img:match("https*:\\/\\/.*")) then+ if not (img:match("https*://.*")) then img = "https://www.koblenz.de" .. img
end
return img
end
end,
- nextpage = function(sel, _)- local link = sel:find(".pagination-next a"):first()- if (link:attr("href"):match("\\/.*")) then- return "https://www.koblenz.de" .. link:attr("href")- end- end,- nextpageattr = "href",- nextpagecount = 25- }- }+ },+ nextpage = ".pagination-next a",+ nextpageattr = "href",+ nextpagecount = 3+ })
diff --git a/selectors.go b/selectors.go
index 842c58a..3a9f01d 100644
--- a/selectors.go+++ b/selectors.go
@@ -62,6 +62,9 @@ func (r *Ratt) NewSelectorsFromLua(sels *lua.LTable) *Selectors {
HTTPSettings: httpsettings.FromLua(sels.RawGetString("httpsettings")),
Feed: feedFromLua(sels.RawGetString("feed")),
Item: itemFromLua(sels.RawGetString("item")),
+ NextPage: sels.RawGetString("nextpage"),+ NextPageAttr: lua.LVAsString(sels.RawGetString("nextpageattr")),+ NextPageCount: int(lua.LVAsNumber(sels.RawGetString("nextpagecount"))), }
return s
}
--
2.42.1