~ghost08/ratt#10: 
[PATCH ratt] ebay-kleinanzeigen: support new page format

From: makefu sr.ht@syntax-fehler.de


confs/ebay-kleinanzeigen.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/confs/ebay-kleinanzeigen.lua b/confs/ebay-kleinanzeigen.lua index 909a168..a072a1d 100644 --- a/confs/ebay-kleinanzeigen.lua +++ b/confs/ebay-kleinanzeigen.lua @@ -1,7 +1,7 @@ -- This configuration allows creating feeds for a german portal for classified ads: ebay-kleinanzeigen.

ratt.add(

  • "https://www.(ebay\\-)?kleinanzeigen.de/s\\-.*", { httpsettings = { useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36", @@ -11,13 +11,13 @@ ratt.add( title = "title" }, item = {
  •       container = "ul[id='srchrslt-adtable'] li[class='ad-listitem lazyload-item   ']",
    
  •       container = "ul[id='srchrslt-adtable'] article",
          title = function(sel, _)
              return sel:find("h2.text-module-begin"):first():text():gsub("^%s*(.-)%s*$", "%1")
          end,
          link = function(sel, _)
              local link = sel:find("a"):first():attr("href")
    
  •           return "https://www.ebay-kleinanzeigen.de" .. link
    
  •           return "https://www.kleinanzeigen.de" .. link
          end,
          created = function(sel, _)
              local created = ""
    
    @@ -32,9 +32,7 @@ ratt.add( local time = created:gsub("^.*,", "") return os.date("%d.%m.%Y", os.time() - 24 * 60 * 60) .. time .. " CET" end
  •           if created:match("\\.") then
    
  •               return created .. " 00:00 CET"
    
  •           end
    
  •           return created .. " 00:00 CET"
          end,
          createdformat = "02.01.2006 15:04 MST",
          description = function(sel, _)
    
    @@ -43,18 +41,18 @@ ratt.add( return description .. place end, image = function(sel, _)
  •           local img = sel:find("div.imagebox"):first():attr("data-imgsrc")
    
  •           local img = sel:find("img"):first():attr("src"):gsub("_%d\+.JPG","_57.JPG")
              if img ~= "" then
                  -- prepend host if needed
    
  •               if not (img:match("https*:\\/\\/.*")) then
    
  •                   img = "https://www.ebay-kleinanzeigen.de" .. img
    
  •               if not (img:match("^https")) then
    
  •                   img = "https://www.kleinanzeigen.de" .. img
                  end
                  return img
              end
          end,
          nextpage = function(sel, _)
              local nextpage = sel:find("link[rel=next]"):attr("href")
    
  •           return "https://www.ebay-kleinanzeigen.de" .. nextpage
    
  •           return "https://www.kleinanzeigen.de" .. nextpage
          end,
          nextpagecount = 5,
      }
    
    -- 2.38.5
Status
RESOLVED FIXED
Submitter
~makefu
Assigned to
No-one
Submitted
10 months ago
Updated
10 months ago
Labels
No labels applied.

~makefu 10 months ago

well, that almost worked, i tried to file a PR similar to github (and failed). patch is:

diff --git a/confs/ebay-kleinanzeigen.lua b/confs/ebay-kleinanzeigen.lua
index 909a168..a072a1d 100644
--- a/confs/ebay-kleinanzeigen.lua
+++ b/confs/ebay-kleinanzeigen.lua
@@ -1,7 +1,7 @@
 -- This configuration allows creating feeds for a german portal for classified ads: ebay-kleinanzeigen.
 
 ratt.add(
-	"https://www.ebay\\-kleinanzeigen.de/s\\-.*",
+	"https://www.(ebay\\-)?kleinanzeigen.de/s\\-.*",
 	{
 		httpsettings = {
 			useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36",
@@ -11,13 +11,13 @@ ratt.add(
 			title = "title"
 		},
 		item = {
-			container = "ul[id='srchrslt-adtable'] li[class='ad-listitem lazyload-item   ']",
+			container = "ul[id='srchrslt-adtable'] article",
 			title = function(sel, _)
 				return sel:find("h2.text-module-begin"):first():text():gsub("^%s*(.-)%s*$", "%1")
 			end,
 			link = function(sel, _)
 				local link = sel:find("a"):first():attr("href")
-				return "https://www.ebay-kleinanzeigen.de" .. link
+				return "https://www.kleinanzeigen.de" .. link
 			end,
 			created = function(sel, _)
 				local created = ""
@@ -32,9 +32,7 @@ ratt.add(
 					local time = created:gsub("^.*,", "")
 					return os.date("%d.%m.%Y", os.time() - 24 * 60 * 60) .. time .. " CET"
 				end
-				if created:match("\\.") then
-					return created .. " 00:00 CET"
-				end
+				return created .. " 00:00 CET"
 			end,
 			createdformat = "02.01.2006 15:04 MST",
 			description = function(sel, _)
@@ -43,18 +41,18 @@ ratt.add(
 				return description .. place
 			end,
 			image = function(sel, _)
-				local img = sel:find("div.imagebox"):first():attr("data-imgsrc")
+				local img = sel:find("img"):first():attr("src"):gsub("_%d\+.JPG","_57.JPG")
 				if img ~= "" then
 					-- prepend host if needed
-					if not (img:match("https*:\\/\\/.*")) then
-						img = "https://www.ebay-kleinanzeigen.de" .. img
+					if not (img:match("^https")) then
+						img = "https://www.kleinanzeigen.de" .. img
 					end
 					return img
 				end
 			end,
 			nextpage = function(sel, _)
 				local nextpage = sel:find("link[rel=next]"):attr("href")
-				return "https://www.ebay-kleinanzeigen.de" .. nextpage
+				return "https://www.kleinanzeigen.de" .. nextpage
 			end,
 			nextpagecount = 5,
 		}

~ghost08 REPORTED FIXED 10 months ago

I've edited it there somehow. There were also some issues with the timestamp for the "TOP" posts, so now they have the current time. Next time please don't send a diff in markdown. Follow please these instructions: https://sr.ht/~ghost08/ratt/#contribution

Thanks for your contribution :)

~makefu 10 months ago

Will do!

Register here or Log in to comment, or comment via email.