aboutsummaryrefslogtreecommitdiff
path: root/_posts/notes/2023-05-23-parse-rss-with-lua.md
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-03-10 14:59:14 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-03-10 14:59:14 +0100
commit1100562e29f6476448b656dbddd4cf22505523f6 (patch)
tree442eec492199104bd49dfd74474ce89ade8fcac9 /_posts/notes/2023-05-23-parse-rss-with-lua.md
parenta40d80be378e46a6c490e1b99b0d8f4acd968503 (diff)
downloadmitjafelicijan.com-1100562e29f6476448b656dbddd4cf22505523f6.tar.gz
Move back to JBMAFP
Diffstat (limited to '_posts/notes/2023-05-23-parse-rss-with-lua.md')
-rw-r--r--_posts/notes/2023-05-23-parse-rss-with-lua.md41
1 files changed, 0 insertions, 41 deletions
diff --git a/_posts/notes/2023-05-23-parse-rss-with-lua.md b/_posts/notes/2023-05-23-parse-rss-with-lua.md
deleted file mode 100644
index ea8ce8c..0000000
--- a/_posts/notes/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```