Opening a stream to a webpage..
BlitzMax Forums/BlitzMax Beginners Area/Opening a stream to a webpage..
| ||
I have the following codeSearchStream = OpenStream("http://www.coreillusions.com/searchforum?q=" + data + "&start=" + page+"") Where data, and page are variables, data being a string and page an integer. But the stream fails to open and then the app crashs inside the brl stream routines when it hits my while eof() loop. Any ideas? |
| ||
If you're just trying to open a webpage in the default browser, feed the concatenated string/url to OpenURL(). Use Driver.OpenURL() instead if you want to access secure servers. Does exactly the same as OpenURL, only it bypasses a bit of prefix checking. If you're trying to read returned data into Blitz, try using ReadStream instead of OpenStream. OpenStream allows both reading and writing, which could be why it isn't working for URLs. |
| ||
I tried readstream with the same result. it simply didnt open /connect the stream. And yes I need access to the ouput in blitz. coding a small tool to parse and scan my forum. |
| ||
Ah. Apparently the url needs to be formatted like this. http::path and not http://path which I dont think is in the documentation, and probably should be. |
| ||
Doh, yea! Had exactly the same problem myself about two weeks ago trying to download images with blitzmax. Think I found the solution in the forum somewhere. |
| ||
Actually still need help. seems that readstream needs the main url and does not actually pass any paramaters onto the page. Is there any way to send data to the page and open a stream to the output ? in a nut shell what my code is trying to do is.. open a stream to a search page and supply a search string and then parse the output ? can this be done ? in max? |
| ||
Never mind .. realized that the I wasnt adding html entities to the string to cover blank space and " and ' etc. |
| ||
For anybody else wanting to know how to download webpages ready for parsing, quick and dirty example:s:TStream = OpenStream("http::www.google.co.uk/search?hl=en&q=blitz&btnG=Search&meta=") If s Repeat l:String = ReadLine(s) Print l Until Eof(s) EndIf CloseStream s |
| ||
Hello. GfK: I used some code from the archives for B3D to read a tcp stream and there was an issue, that I managed to overcome, whereby if you actually reached EOF there would be a, comparitively, huge delay before control was returned to the application. Is this an issue here? Goodbye. |
| ||
No. I only tested the code a couple of times, but the program exited as soon as the end of the file was reached. |