Code archives/Networking/HTML WEB READER BMX

This code has been declared by its author to be Public Domain code.

Download source code

HTML WEB READER BMX by warwulf2012
this reads html code from a website
HTTPReader("www.blitzbasic.com")
Function HTTPReader$(url$)
	Local stream:TStream = OpenStream("http::" + url$,80)
	If Not stream Then Return -1
	stream.WriteLine "HEAD " + file$ + " HTTP/1.1"
	stream.WriteLine "Host: " + host$
	While Not Eof(stream) ; Print stream.ReadLine() ; Wend
	stream.Close()
	Return header$
End Function

Comments

Gauge2014
In this example what would file$ and host$ be?


xlsior2014
I'd assume the following, based on the HTTP specs:

Host would be the hostname of the website (e.g. "www.blitzbasic.com" -- this is what the server uses to detect the website you want, since under HTTP1.1 multiple sites can share a single IP address)

file would contain the path+filename, e.g. "codearcs/codearcs.php"

If you do NOT know a file/folder name and simply want to go to the default main page of a site, specify "/" as the filename, which will tell it to open the default document in the root folder of the website.


Brucey2014
It's basically a really bad, incomplete example of doing something. There are probably better examples elsewhere.


Code Archives Forum