This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TyDoesMC's profile picture

Get strings from a website

Started by TyDoesMC, 11 May 2015 - 02:47 PM
TyDoesMC #1
Posted 11 May 2015 - 04:47 PM
Hello, I am trying to make a program that grabs strings/variables from a custom site, the site will have a members and you can signup and post your variables then it'll have a link and then the program will look at those links for those variables. let me explain better:
1st you create a program, then you use my program to make an updater or other things for your program, goto the site signup/login, make variables that the updater will use like what version to display the description ect. the program will grab all of em and use them accordingly.
Lignum #2
Posted 11 May 2015 - 05:42 PM
You can use the http api to make http requests. Without knowing the specifics, we can't help you much further than that.
Creator #3
Posted 11 May 2015 - 05:45 PM
The part of grabbing the variables would work like this (be sure to take a look at the http api too):


local site = http.get(siteLink)
local data = site.read()

You'll still want to use raw pages like github and pastebin because else you'll get all the html, not only the data.

ninja'd
TyDoesMC #4
Posted 11 May 2015 - 06:48 PM
Ok thankyou, I changed my mind about the updater could I make a login with this? could I possibly get a short non secure demo? how would I declare that the contents on that page is a username and or a password?

Oh one last thing, is it possible to link CC with webs/weebly members on my site?
Creator #5
Posted 11 May 2015 - 06:53 PM
Take a look at the http api and learn about the different functions. There is also http.post and http.request.
TyDoesMC #6
Posted 11 May 2015 - 06:57 PM
Ok thankyou, you should be a mod IMO you take time to explain and give a short demo, You know your stuff around LUA/CC. Im not new to LUA/CC just HTTP API.
If I give an example and you see any errors could you help me fix it?
Creator #7
Posted 11 May 2015 - 07:09 PM
Well, I could try to, but I don't get the http api so well either. Anyway I'll be happy to be helpful ;)/>

Thanks
KingofGamesYami #8
Posted 11 May 2015 - 07:22 PM
I understand the http api, but I don't understand PHP, so… I can only do so much.

http.get executes a GET request to the url provided, used for things like Getting the contents of a github repo, or other information that is non-changing.

http.post executes a POST request to the url provided, used for when the PHP script requires input from the client. For example, you could send a username / password to the script, and the script sends back an auth token that is then sent with all subsequent requests, so the server knows who is communicating with it.
TyDoesMC #9
Posted 11 May 2015 - 07:29 PM
I seemed to of run into a problem, I'm still in highschool grade 10, and http wont work on an emulator, before you say do school work its my spare and could this be from the restricted wifi or the emulator or the fact im using a school computer?…
Lyqyd #10
Posted 11 May 2015 - 07:41 PM
I would highly advise not using school-owned computers for anything other than the acceptable uses detailed in the computer use agreement that you and/or your parents signed.
TyDoesMC #11
Posted 13 May 2015 - 09:10 PM
Never signed anything :/ but yea its the restricted wifi, computers are free to use here. and games are allowed but when your told by the teacher or when its lunch.