Problem with http.Fetch()

Hi,

I am trying to use http.Fetch to print the HTML of a webpage. Here is the webpage HTML:

<!DOCTYPE html>
<html>
Hello! This is a fetch test.
</html>

And here’s the file I run using lua_openscript_cl


local theReturnedHTML = "" -- Blankness

http.Fetch( "http://potpankettle.lovestoblog.com/fetch.html",
	
	-- onSuccess function
	function( body, length, headers, code )
		-- The first argument is the HTML we asked for.
		theReturnedHTML = body
		print( theReturnedHTML )
	end,

	-- onFailure function
	function( message )
		-- We failed. =(
		print( message )
	end,

	-- header example
	{ 
		["accept-encoding"] = "gzip, deflate",
		["accept-language"] = "fr" 
	}
)



However, when I run this, rather than getting “Hello! This is a fetch test.” printed to console, I get some strange html block about javascript as the console output:

<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("41761c8ad21f208fbaafec257ec40520");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://potpankettle.lovestoblog.com/fetch.html?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>

Any help would be appreciated. Thank you!

Are you running on the x86-64 branch? If not, try switching to that and see if it works.

I think this is your problem.

It would seem that the webserver injects a piece of JavaScript that replaces the page’s contents with the actual contents of your fetch.html file.

I don’t know if you set that up or if this free hosting provider set that up but it looks specifically designed to stop you from doing exactly this. They only want actual web browsers to access the page contents, I suppose.