Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Write text to remote URL.txt.[Help]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1550

PostPosted: Tue Aug 06, 2019 5:32 pm    Post subject: Write text to remote URL.txt.[Help] Reply with quote

Write text to remote URL.txt.
Can I write to a "Document" file via its url?
Is there a way to do that?
Or should I "simulate" all the steps?

Code:
function Write()
local url = 'https://docs.google.com/document/d/1cvHv3L14MjqTQavpnUVRkvDf6z4_Ss5_y60F7xj__mw/edit'
local int = getInternet()
local text = int.getURL(url)
--int.destroy()
local ss = int.getURL(text.."w") --int.getURL or io.open or getInternet or ...?
    if (ss ~= nil) then
    local ad = "Admin: "
      ss:write(control_getCaption(UDF1.CEEdit1, ad, "*a"))
ss:close()
int.destroy()
  end
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Aug 07, 2019 1:32 am    Post subject: Reply with quote

getInternet() object returns an object that includes:
- getURL
- postURL

You'd want to use postURL. Params are:
Code:
postURL(url, post_args)


post_args are in URL encoded format like:
test=1&hello=2&world=3

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1550

PostPosted: Wed Aug 07, 2019 5:10 am    Post subject: Reply with quote

Thanks @ atom0s for the answer.
Is it possible for you to comment or edit in the code?
I'm confused again. Smile

Is there an example with the above code, or an example that can work?

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Aug 07, 2019 12:57 pm    Post subject: Reply with quote

You can see an example of it in use here:
https://github.com/cheat-engine/cheat-engine/blob/c7e69c7b4c21f0d057b66fd090a2b898c05520b3/Cheat%20Engine/bin/autorun/ceshare.lua#L31

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1550

PostPosted: Wed Aug 07, 2019 4:21 pm    Post subject: Reply with quote

Yes, I've seen this while browsing with Google.
But the following code gives an error.

xmlSimple.lua:

Code:
module(..., package.seeall)

---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
--
-- Original source: https://github.com/Cluain/Lua-Simple-XML-Parser
--
-- xml.lua - XML parser for use with the Corona SDK.
--
-- version: 1.2
--
-- CHANGELOG:
--
-- 1.2 - Created new structure for returned table
-- 1.1 - Fixed base directory issue with the loadFile() function.
--
-- NOTE: This is a modified version of Alexander Makeev's Lua-only XML parser
-- found here: http://lua-users.org/wiki/LuaXml
--
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
function newParser()

    XmlParser = {};

    function XmlParser:ToXmlString(value)
        value = string.gsub(value, "&", "&"); -- '&' -> "&"
        value = string.gsub(value, "<", "&lt;"); -- '<' -> "&lt;"
        value = string.gsub(value, ">", "&gt;"); -- '>' -> "&gt;"
        value = string.gsub(value, "\"", "&quot;"); -- '"' -> "&quot;"
        value = string.gsub(value, "([^%w%&%;%p%\t% ])",
            function(c)
                return string.format("&#x%X;", string.byte(c))
            end);
        return value;
    end

    function XmlParser:FromXmlString(value)
        value = string.gsub(value, "&#x([%x]+)%;",
            function(h)
                return string.char(tonumber(h, 16))
            end);
        value = string.gsub(value, "&#([0-9]+)%;",
            function(h)
                return string.char(tonumber(h, 10))
            end);
        value = string.gsub(value, "&quot;", "\"");
        value = string.gsub(value, "&apos;", "'");
        value = string.gsub(value, "&gt;", ">");
        value = string.gsub(value, "&lt;", "<");
        value = string.gsub(value, "&amp;", "&");
        return value;
    end

    function XmlParser:ParseArgs(node, s)
        string.gsub(s, "(%w+)=([\"'])(.-)%2", function(w, _, a)
            node:addProperty(w, self:FromXmlString(a))
        end)
    end

    function XmlParser:ParseXmlText(xmlText)
        local stack = {}
        local top = newNode()
        table.insert(stack, top)
        local ni, c, label, xarg, empty
        local i, j = 1, 1
        while true do
            ni, j, c, label, xarg, empty = string.find(xmlText, "<(%/?)([%w_:]+)(.-)(%/?)>", i)
            if not ni then break end
            local text = string.sub(xmlText, i, ni - 1);
            if not string.find(text, "^%s*$") then
                local lVal = (top:value() or "") .. self:FromXmlString(text)
                stack[#stack]:setValue(lVal)
            end
            if empty == "/" then -- empty element tag
                local lNode = newNode(label)
                self:ParseArgs(lNode, xarg)
                top:addChild(lNode)
            elseif c == "" then -- start tag
                local lNode = newNode(label)
                self:ParseArgs(lNode, xarg)
                table.insert(stack, lNode)
      top = lNode
            else -- end tag
                local toclose = table.remove(stack) -- remove top

                top = stack[#stack]
                if #stack < 1 then
                    error("XmlParser: nothing to close with " .. label)
                end
                if toclose:name() ~= label then
                    error("XmlParser: trying to close " .. toclose.name .. " with " .. label)
                end
                top:addChild(toclose)
            end
            i = j + 1
        end
        local text = string.sub(xmlText, i);
        if #stack > 1 then
            error("XmlParser: unclosed " .. stack[#stack]:name())
        end
        return top
    end

    function XmlParser:loadFile(xmlFilename, base)
        if not base then
            base = system.ResourceDirectory
        end

        local path = system.pathForFile(xmlFilename, base)
        local hFile, err = io.open(path, "r");

        if hFile and not err then
            local xmlText = hFile:read("*a"); -- read file content
            io.close(hFile);
            return self:ParseXmlText(xmlText), nil;
        else
            print(err)
            return nil
        end
    end

    return XmlParser
end

function newNode(name)
    local node = {}
    node.___value = nil
    node.___name = name
    node.___children = {}
    node.___props = {}

    function node:value() return self.___value end
    function node:setValue(val) self.___value = val end
    function node:name() return self.___name end
    function node:setName(name) self.___name = name end
    function node:children() return self.___children end
    function node:numChildren() return #self.___children end
    function node:addChild(child)
        if self[child:name()] ~= nil then
            if type(self[child:name()].name) == "function" then
                local tempTable = {}
                table.insert(tempTable, self[child:name()])
                self[child:name()] = tempTable
            end
            table.insert(self[child:name()], child)
        else
            self[child:name()] = child
        end
        table.insert(self.___children, child)
    end

    function node:properties() return self.___props end
    function node:numProperties() return #self.___props end
    function node:addProperty(name, value)
        local lName = "@" .. name
        if self[lName] ~= nil then
            if type(self[lName]) == "string" then
                local tempTable = {}
                table.insert(tempTable, self[lName])
                self[lName] = tempTable
            end
            table.insert(self[lName], value)
        else
            self[lName] = value
        end
        table.insert(self.___props, { name = name, value = self[name] })
    end

    return node
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Aug 07, 2019 7:19 pm    Post subject: Reply with quote

Aylin wrote:
Yes, I've seen this while browsing with Google.
But the following code gives an error.


To read or get what is the text contains from your file on google docs, you don't need parsing all Html code, That can be done by changing your google docs URL :

from :

Code:
url = 'https://docs.google.com/document/d/1cvHv3L14MjqTQavpnUVRkvDf6z4_Ss5_y60F7xj__mw/edit'


to :

Code:
url = 'https://docs.google.com/document/d/1cvHv3L14MjqTQavpnUVRkvDf6z4_Ss5_y60F7xj__mw/export?format=txt'


-- see the change is 'edit' to 'export?format=txt' on the match Url

so with this code:

Code:
local url = 'https://docs.google.com/document/d/1cvHv3L14MjqTQavpnUVRkvDf6z4_Ss5_y60F7xj__mw/export?format=txt'
local int = getInternet()
local text = int.getURL(url)
print(text)

-- will give the results:

aaaaaaaaaaaaaa
bbbbbbbbbbbbbb
ccccccccccccccc

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1550

PostPosted: Thu Aug 08, 2019 7:53 am    Post subject: Reply with quote

Corroder wrote:

To read or get what is the text contains from your file on google docs, you don't need parsing all Html code, That can be done by changing your google docs URL :


Yes I used the code above. Wink

https://docs.google.com/document/d/1cvHv3L14MjqTQavpnUVRkvDf6z4_Ss5_y60F7xj__mw/edit

But I want to send a letter to the same document.
Document settings:
All users can edit.
No login required.
Available online and off.
Important permissions have been granted and shared.
But I still can't write "Hello World" from a distance. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Aug 08, 2019 1:23 pm    Post subject: Reply with quote

It's easier to create/write text on Pastebin, by using their API parameters, for example:

Code:
url= 'https://pastebin.com/api/api_post.php'  -- this is url provide by pastebin to allows people creating a new paste/file
api_dev_key = '5f6da4d40eadc258f36114eea7adf72a' -- this my developers key on pastebin
api_paste_code='Hello World' -- this is the text to write on pastebin

local int = getInternet()
int.postURL(url,'api_option=paste&api_dev_key='..api_dev_key..'&api_paste_code='..api_paste_code..'')
response = int.postURL(url,'api_option=paste&api_dev_key='..api_dev_key..'&api_paste_code='..api_paste_code..'')
print(response)

-- the good response will be: https://pastebin.com/i9dpQYSR
-- then try open the response URL, 'Hello World' is there


I don't know if google docs/drive have API parameters too which use for write text/post file via scripting.
Try to search keyword 'Google docs API'

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites