Parse html file

BlitzPlus Forums/BlitzPlus Programming/Parse html file

hub(Posted 2003) [#1]
Hi !
i want produce a software with b+ to know if someone is connected to my site. My site use php with mysql database.

The idea is to create a php page which contains the list of the connected members. Next, in b+, i create an html view gadget (its url should be the php page url). Each 2 minutes i actualise the view... Next i want parse the htmlview gadget html source file. This is my problem... how to access to the html source file ?

Thanks !


Difference(Posted 2003) [#2]
Why not have php write out a plain text file, and get that?

Anyway, check this out ( HTTPGet ) : http://www.blitzbasic.com/codearcs/codearcs.php?code=21

The htmlview gadget aproach seems a bit bloated, compared to reading the file directly.


hub(Posted 2003) [#3]
Thanks for your help peter, i don't know that it was possible to do that !


Difference(Posted 2003) [#4]
I just checked, and found that the example in the help file under OpenTCPStream() is easier to use and understand.

change the get line to read:

WriteLine tcp,"GET http://www.mydomain.com/test.html HTTP/1.0" or whatver page you want.


hub(Posted 2003) [#5]
Thanks a lot peter !


Idiot(Posted 2003) [#6]
This seems to take a long time to get even a small amount of data back. I think the htmlview gadget is actually faster. If this is the case it would be great to be able to read the source text from the htmlview.


Jim Teeuwen(Posted 2003) [#7]
it takes too long because the TCP stream is waiting for stream termination. This can take a bit sometimes.

I suggest you have your php page put some character like * at the end of the textfile.
Then just read the tcp stream from blitz byte by byte until you reach that * character. After this you can manually close the stream immediatly. This works a ton faster.


MagicalTux(Posted 2003) [#8]
Just use that piece of code after you open your TCP Stream :

WriteLine tcp,"GET /test.html HTTP/1.0"
WriteLine tcp,"Host: www.mydomain.com"
WriteLine tcp,"Connection: Close" ; ask the web serv to close after data sent
WriteLine tcp,"" ; send an empty line to confirm the HTTP/1.0 query


I use that with my Apache 1.3.27 server :p