.lua-files/test.lua

22 lines
792 B
Lua
Raw Normal View History

2024-01-14 00:17:31 +00:00
#!/usr/bin/env luajit
2024-11-06 04:54:00 +00:00
local success, utility = pcall(function()
return dofile((arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "utility-functions.lua")
end)
if not success then
print("\n\n" .. tostring(utility))
error("\n\nThis script may be installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n")
end
2024-01-14 00:17:31 +00:00
2024-11-09 07:42:41 +00:00
local htmlparser = utility.require("htmlparser")
utility.open("TEST.html", "r")(function(html_file)
local raw_html = html_file:read("*all")
2024-01-14 00:17:31 +00:00
2024-11-09 07:42:41 +00:00
local parser = htmlparser.parse(raw_html)
local content_tag = parser:select(".article > div > div") -- TODO add ability to set selector in config!
local text = content_tag[1]:getcontent()
2024-11-09 07:42:41 +00:00
local title_tag = parser:select(".headline")
print(title_tag[1]:gettext())
end)