Fetch website contents

Hello, I was wondering how I could make a script fetch the contents of a website? So for example the website is blank and only says “Hello” how could I make it fetch the website contents then print what is on the website so it would print “Hello” into the game?

I was trying these scripts but I seem to get an error. “attempt to index a nil value (global ‘http’)”

https://nodemcu.readthedocs.io/en/master/en/modules/http/#httpget

Nice release bro 11/10

2 Likes

@CrazyCorrs How do I install this into my game?

This isn’t a release its a discussion post…

@CrazyCorrs try something like this (Providing your doing it in lua):

PerformHttpRequest("http://address.here/file.txt", function(err, rText, headers)
	print("Return: "..rText)
end, "GET", "", {what = 'this'}) 

EDIT

As per your second message you seem to be trying to do this through NodeJS or some equivalent of. it would help if you shared your code so we could help but just a guess try including the http core package within NodeJS: var http = require('http');

I haven’t got a code, I tried to google how to fetch website content via lua and that is what it gave me. I am gong to try your code now!

sure no worries, feel free to get me on discord or through here via dm if you like