aboutsummaryrefslogtreecommitdiff
path: root/_posts/2023-05-23-parse-rss-with-lua.md
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-02-23 10:35:22 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-02-23 10:35:22 +0100
commit4abcce013c9ee3053badf2abda77190233066676 (patch)
tree450de7e8fed3c3c7501a9d2e2eb60a676bdfa09e /_posts/2023-05-23-parse-rss-with-lua.md
parentcdf50cb2e3051200c6ea0628c318d66220b7d1a1 (diff)
downloadmitjafelicijan.com-4abcce013c9ee3053badf2abda77190233066676.tar.gz
Testing thoughts page
Diffstat (limited to '_posts/2023-05-23-parse-rss-with-lua.md')
-rw-r--r--_posts/2023-05-23-parse-rss-with-lua.md41
1 files changed, 0 insertions, 41 deletions
diff --git a/_posts/2023-05-23-parse-rss-with-lua.md b/_posts/2023-05-23-parse-rss-with-lua.md
deleted file mode 100644
index ea8ce8c..0000000
--- a/_posts/2023-05-23-parse-rss-with-lua.md
+++ /dev/null
@@ -1,41 +0,0 @@
1---
2title: Parse RSS feeds with Lua
3permalink: /parse-rss-with-lua.html
4date: 2023-05-23T12:00:00+02:00
5layout: post
6type: note
7draft: false
8tags: [lua, rss]
9---
10
11Example of parsing RSS feeds with Lua. Before running the script install:
12
13- feedparser with `luarocks install feedparser`
14- luasocket with `luarocks install luasocket`
15
16```lua
17local http = require("socket.http")
18local feedparser = require("feedparser")
19
20local feed_url = "https://mitjafelicijan.com/index.xml"
21
22local response, status, _ = http.request(feed_url)
23if status == 200 then
24 local parsed = feedparser.parse(response)
25
26 -- Print out feed details.
27 print("> Title ", parsed.feed.title)
28 print("> Author ", parsed.feed.author)
29 print("> ID ", parsed.feed.id)
30 print("> Entries ", #parsed.entries)
31
32 for _, item in ipairs(parsed.entries) do
33 print("GUID ", item.guid)
34 print("Title ", item.title)
35 print("Link ", item.link)
36 print("Summary ", item.summary)
37 end
38else
39 print("! Request failed. Status:", status)
40end
41```