SyntaxBomb - Indie Coders
Languages & Coding => Blitz Code Archives => Networking => Topic started by: BlitzBot on June 29, 2017, 00:28:43
Title : HTML WEB READER BMX
Author : warwulf
Posted : 1+ years ago
Description : this reads html code from a website
Code :
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 :
Gauge(Posted 1+ years ago)
In this example what would file$ and host$ be?
xlsior(Posted 1+ years ago)
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.
Brucey(Posted 1+ years ago)
It's basically a really bad, incomplete example of doing something. There are probably better examples elsewhere.