diff options
Diffstat (limited to 'content/notes')
| -rw-r--r-- | content/notes/non-blocking-shell-exec-csharp.md | 2 | ||||
| -rw-r--r-- | content/notes/parse-rss-with-lua.md | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/content/notes/non-blocking-shell-exec-csharp.md b/content/notes/non-blocking-shell-exec-csharp.md index 4ac3904..6de081e 100644 --- a/content/notes/non-blocking-shell-exec-csharp.md +++ b/content/notes/non-blocking-shell-exec-csharp.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Execute not blocking async shell command in C# | 2 | title: Execute not blocking async shell command in C# |
| 3 | url: non-blocking-shell-exec-csharp.html | 3 | url: non-blocking-shell-exec-csharp.html |
| 4 | date: 2023-05-24 | 4 | date: 2023-05-22 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [csharp, async, shell] | 7 | tags: [csharp, async, shell] |
diff --git a/content/notes/parse-rss-with-lua.md b/content/notes/parse-rss-with-lua.md new file mode 100644 index 0000000..9c7ca84 --- /dev/null +++ b/content/notes/parse-rss-with-lua.md | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | --- | ||
| 2 | title: Parse RSS feeds with Lua | ||
| 3 | url: parse-rss-with-lua.html | ||
| 4 | date: 2023-05-24 | ||
| 5 | type: notes | ||
| 6 | draft: false | ||
| 7 | tags: [lua, rss] | ||
| 8 | --- | ||
| 9 | |||
| 10 | Example of parsing RSS feeds with Lua. Before running the script install: | ||
| 11 | - feedparser with `luarocks install feedparser` | ||
| 12 | - luasocket with `luarocks install luasocket` | ||
| 13 | |||
| 14 | ```lua | ||
| 15 | local http = require("socket.http") | ||
| 16 | local feedparser = require("feedparser") | ||
| 17 | |||
| 18 | local feed_url = "https://mitjafelicijan.com/feed.rss" | ||
| 19 | |||
| 20 | local response, status, _ = http.request(feed_url) | ||
| 21 | if status == 200 then | ||
| 22 | local parsed = feedparser.parse(response) | ||
| 23 | |||
| 24 | -- Print out feed details. | ||
| 25 | print("> Title ", parsed.feed.title) | ||
| 26 | print("> Author ", parsed.feed.author) | ||
| 27 | print("> ID ", parsed.feed.id) | ||
| 28 | print("> Entries ", #parsed.entries) | ||
| 29 | |||
| 30 | for _, item in ipairs(parsed.entries) do | ||
| 31 | print("GUID ", item.guid) | ||
| 32 | print("Title ", item.title) | ||
| 33 | print("Link ", item.link) | ||
| 34 | print("Summary ", item.summary) | ||
| 35 | end | ||
| 36 | else | ||
| 37 | print("! Request failed. Status:", status) | ||
| 38 | end | ||
| 39 | ``` | ||
