 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Wed May 29, 2019 12:39 am Post subject: Lua >>request >>socket.http |
|
|
| Code: | local http= require("socket.http")
local url= 'https://forum.cheatengine.org/viewtopic.php?t=610183'
local resp = http.request(url)
print(resp) |
I want to get web content, not source code。
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed May 29, 2019 1:02 am Post subject: |
|
|
| Code: | local int=getInternet()
local url='https://forum.cheatengine.org/viewtopic.php?t=610183'
local resp=int.getURL(url)
print(resp) |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Wed May 29, 2019 1:07 am Post subject: |
|
|
| Corroder wrote: | | Code: | local int=getInternet()
local url='https://forum.cheatengine.org/viewtopic.php?t=610183'
local resp=int.getURL(url)
print(resp) |
|
I just want the content of the page, not the source code.
|
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1526
|
|
| Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Wed May 29, 2019 6:32 am Post subject: |
|
|
| Aylin wrote: | Some older codes can give you ideas.
But the need to merge quite challenging.
Example code: http.lua |
So much code, I am very helpless.
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Wed May 29, 2019 6:54 am Post subject: |
|
|
The "content" of an HTML page is the full HTML. If you want a certain element you'll need to parse the HTML for the element you want. There are a lot of HTML parsers for Lua, just use google to find one and how to use it. Then combine that with what Corroder showed you.
_________________
|
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1526
|
Posted: Wed May 29, 2019 7:16 am Post subject: |
|
|
The code you started is pointing in the right direction.
But from the link I've made, get the necessary codes.
Meet the ".lua" requests with the desired names in the error list.
etc .. etc ..
img.: https://i.hizliresim.com/p54lln.png
Here you can find the desired documents.
http (lua server) : https://github.com/mode777/LuaJitServer
_________________
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed May 29, 2019 7:26 am Post subject: |
|
|
| Quote: | | I just want the content of the page, not the source code. |
Here:
| Code: | local int=getInternet()
local url='https://forum.cheatengine.org/viewtopic.php?t=610183'
local resp=int.getURL(url)
print(resp)
local frm = getLuaEngine()
local log = frm.mOutput.Lines.Text
path = TrainerOrigin or getMainForm()
local f = assert(io.open("content.html", "w"))
f:write(log)
f:close()
local name = path .. "\\content.html"
os.execute(name) |
Copy that code above to script table and save as CT file first. Next, re-open the CT file you saved
and execute to match 'path' given.
Or you can change 'path = TrainerOrigin or getMainForm()' to another path like "E:\\content.html", what ever.
This will be doing the same as you open the provided URL with a web browser. That is the 'Content' as you meant. Then if I still not understand with you meant of 'content' then do what @TheyCallMeTim said, parse the URL result.
Here is a sample the HTML parser from the URL you provided.
| Code: | nl = "\n"
function HTML_ToText (file)
local text
local f=io.open (file)
if f then
if f:seek("end") <= 0 then return end
f:seek("set")
text = f:read ("*a")
f:close()
end
text = string.gsub (text,"(<([^>]-)>)",function (str) return str:lower() end)
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
text = string.gsub (text, "(<%s*td[^>]*>)","\t")
text = string.gsub (text, "(<%s*th[^>]*>)","\t")
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
local addresses,c = {},0
text=string.gsub(text,"<%s*a.-href=[\'\"](%S+)[\'\"][^>]*>(.-)<%s*%/*%s*a[^>]->",
function (url,name)
c = c + 1
name = string.gsub (name, "<([^>]-)>","")
if name:find("%w") then print(url, name, c) table.insert (addresses, {url, name}) return name.."["..#addresses.."]" else return "" end
end)
text = string.gsub (text, "(%b<>)","")
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%;)" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
[" "] = " ",
["•"] = " * ",
["‹"] = "<",
["›"] = ">",
["™"] = "(tm)",
["⁄"] = "/",
["<"] = "<",
[">"] = ">",
["©"] = "(c)",
["®"] = "(r)",
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
if #addresses > 0 then
text=text..nl:rep(2)..("-"):rep(2)..nl
for key, tbl in ipairs(addresses) do
text = text..nl.."["..key.."]"..tbl[1]
end
end
return text
end
---------------------------Test Parsing
local int=getInternet()
local url='https://forum.cheatengine.org/viewtopic.php?t=610183'
local resp=int.getURL(url)
print(resp)
local frm = getLuaEngine()
local log = frm.mOutput.Lines.Text
path = TrainerOrigin or getMainForm()
local f = assert(io.open("content.html", "w"))
f:write(log)
f:close()
frm.mOutput.Clear()
local filename = path .. "\\content.html"
local f=io.open(filename..".txt", "w")
f:write(HTML_ToText (filename))
f:close()
os.remove(path.."\\content.html")
--os.rename(path.."\\content.html.txt","content.txt")
--os.execute(path.."\\content.txt")
note = [[
Check the provided path for a file name 'content.html.txt'
and open with notepad to see parsed webpage contents.
]]
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Wed May 29, 2019 10:19 am Post subject: |
|
|
| Corroder wrote: | | Quote: | | I just want the content of the page, not the source code. |
Copy that code above to script table and save as CT file first. Next, re-open the CT file you saved
and execute to match 'path' given.
Or you can change 'path = TrainerOrigin or getMainForm()' to another path like "E:\\content.html", what ever.
This will be doing the same as you open the provided URL with a web browser. That is the 'Content' as you meant. Then if I still not understand with you meant of 'content' then do what @TheyCallMeTim said, parse the URL result.
Here is a sample the HTML parser from the URL you provided. |
The dialogue we can see is exactly what I want.
| Description: |
|
| Filesize: |
170.98 KB |
| Viewed: |
3619 Time(s) |

|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|