-- Example method: every with non-empty text becomes an item. local root = ... local items = {} for _, a in ipairs(root:find_all("a")) do local href = a:attr("href") local text = a:text() if href and href ~= "" and text and text ~= "" then table.insert(items, { title = text, link = href }) end end return items