1. DLL question
- Posted by Hallvard Ystad <euphoria at babelserver.org> Jul 08, 2006
- 682 views
- Last edited Jul 09, 2006
Hello folks, I found the URL Moniker wrapper in the archive and wonder how to download a URL, not to a file, but to a string. I looked at the urlmon.dll file and found what looks to me like several method names indicating it should be possible, but I know too little about this dll. Does anyone know how to accomplish it? Thanks, HY
2. Re: DLL question
- Posted by C Bouzy <eucoder at hotmail.com> Jul 09, 2006
- 650 views
Hi Try Asynchronous HTTP by Thomas Parslow. http://www.rapideuphoria.com/http.zip ----If you continue to do what you have always done, you will get what you have always gotten.----
3. Re: DLL question
- Posted by don cole <doncole at pacbell.net> Jul 09, 2006
- 664 views
Hallvard Ystad wrote: > > Hello folks, > > I found the URL Moniker wrapper in the archive and wonder how to download a > URL, not to a file, but to a string. > > I looked at the urlmon.dll file and found what looks to me like several method > names indicating it should be possible, but I know too little about this dll. > > Does anyone know how to accomplish it? > > Thanks, > HY Hello HY, This is what I use:
include urlmon.ew -- atom lastTime,lastProgress function OnProgress(atom progress,atom progressMax,atom status,atom statusText) atom t,dt,speed if status=URLMON_BEGINDOWNLOADDATA then puts(1,"Starting download\n") elsif status=URLMON_ENDDOWNLOADDATA then puts(1,"\n\nDownload finished!*\n") elsif status=URLMON_DOWNLOADINGDATA then t = time() dt = t-lastTime if dt=0 then dt=0.001 end if speed = (progress-lastProgress)/dt if speed=0 then speed=0.001 end if lastTime = t lastProgress = progress position(5,1) printf(1,"%d of %d kB done at %1.2f kB/s. %d seconds remaining ", floor({progress,progressMax,speed,(progressMax-progress)/speed}/1024)) puts(1,"\nPress [ESC] to abort download") elsif status=URLMON_CONNECTING then puts(1,"Connecting to host..\n") elsif status=URLMON_SENDINGREQUEST then puts(1,"Requesting file..\n") end if if get_key()=27 then puts(1,"\n\nDownload aborted!\n") --pause() return URLMON_ABORT end if return 0 end function ------------------------------start of program------------------------- -------------------------download---------------------------- global procedure download(sequence webpage,sequence asp_loc) atom result,fn3 puts(1,"Starting Program...\n") fn3=open(asp_loc,"w") ?fn3 close (fn3) lastTime = time() lastProgress = 0 result = URLDownloadToFile(webpage, asp_loc, call_back(routine_id("OnProgress")), 0) if result then puts(1,"Download failed!*\n") ?result --pause() end if for x= 1 to 10 do ?x end for end procedure
Don Cole
4. Re: DLL question
- Posted by Hallvard Ystad <euphoria at babelserver.org> Jul 09, 2006
- 656 views
Thanks C Bouzy and Don Cole, but 1) I need *synchronous* http (need to fetch certain data via http when in a CGI script), and 2) I want the data in a string, not written to a file (because I don't want to reread the contents from the disk) I *think* this is possible with the urlmon.dll. There seems to be methods in it with names like URLDownloadW and URLDownloadA. I just don't know how to wrap them in euphoria. Thanks in advance, HY Prætera censeo Carthaginem esse delendam
5. Re: DLL question
- Posted by Hallvard Ystad <euphoria at babelserver.org> Jul 09, 2006
- 648 views
Second thought: http://msdn.microsoft.com/workshop/networking/moniker/monikers.asp doesn't seem to tell that the DLL knows how to give the contents of a URL to a string, so maybe I'm mistaken. The method names that I saw inside the DLL are not mentioned on that site... Still hoping, though, HY Hallvard Ystad wrote: > > Thanks C Bouzy and Don Cole, but > > 1) I need *synchronous* http (need to fetch certain data via http when in a > CGI script), and > 2) I want the data in a string, not written to a file (because I don't want > to reread the contents from the disk) > > I *think* this is possible with the urlmon.dll. There seems to be methods in > it with names like URLDownloadW and URLDownloadA. I just don't know how to > wrap > them in euphoria. > > Thanks in advance, > HY > Prætera censeo Carthaginem esse delendam
6. Re: DLL question
- Posted by don cole <doncole at pacbell.net> Jul 09, 2006
- 637 views
Hallvard Ystad wrote: > > Thanks C Bouzy and Don Cole, but > > 1) I need *synchronous* http (need to fetch certain data via http when in a > CGI script), and > 2) I want the data in a string, not written to a file (because I don't want > to reread the contents from the disk) > > I *think* this is possible with the urlmon.dll. There seems to be methods in > it with names like URLDownloadW and URLDownloadA. I just don't know how to > wrap > them in euphoria. > > Thanks in advance, > HY > Prætera censeo Carthaginem esse delendam Hello HY, The way access the code I sent you is: download("Http://www.mywebsite.html","c:\\download.asp") This will download the webpage and save it as an .asp file (which is a .txt file. Then you must go through that .asp file with: (untested)
sequence line integer fn fn=open("c:\\download.asp") while 1 do line=gets(fn) if line=-1 then exit end if puts(1,line&"\n")--here you must study that line and see what triggers -- certain data via http when in a CGI script. -- then extract only that data and save it.
end while
Don Cole }}}
7. Re: DLL question
- Posted by Hallvard Ystad <euphoria at babelserver.org> Jul 10, 2006
- 683 views
don cole wrote: > Hello HY, > The way access the code I sent you is: > download("Http://www.mywebsite.html","c:\\download.asp") > This will download the webpage and save it as an .asp file (which is a .txt > file. I know. The thing is, I don't want to write this to a file on the local disk and then reread it into a string. Why do two disk operations when I can do none? Unfortunately, I know too little about native windows programming and euphoria dll wrapping. Have been trying to figure out some of it, but didn't seem to get the right results. According to http://msdn.microsoft.com/workshop/networking/moniker/reference/functions/urlmon_ref_functions_entry.asp the URLOpenStream function creates a push type stream object from a URL. Could this stream be turned into a euphoria sequence (string)? Are there any volunteers to wrap this function for me? The original URL Moniker DLL wrapper in euphoria is here: http://www.rapideuphoria.com/urlmon.zip. If there are no volunteers, I won't bother the list with this anymore. Thanks, HY
8. Re: DLL question
- Posted by C Bouzy <eucoder at hotmail.com> Jul 11, 2006
- 740 views
Hallvard Ystad wrote: > > I know. The thing is, I don't want to write this to a file on the local disk > and then reread it into a string. Why do two disk operations when I can do > none? > That is why I sent you to the link to Asynchronous HTTP by Thomas Parslow, it does exactly what you want. ---- C Bouzy ----If you continue to do what you have always done, you will get what you have always gotten.----
9. Re: DLL question
- Posted by don cole <doncole at pacbell.net> Jul 11, 2006
- 702 views
Hallvard Ystad wrote: > > I know. The thing is, I don't want to write this to a file on the local disk > and then reread it into a string. Why do two disk operations when I can do > none? > I hope you mean "when I can do one". I'd like to see a sample of this webpage you are trying to get text from. Don Cole
10. Re: DLL question
- Posted by Hallvard Ystad <euphoria at babelserver.org> Jul 12, 2006
- 693 views
C Bouzy wrote: > That is why I sent you to the link to Asynchronous HTTP by Thomas Parslow, > it does exactly what you want. ..except that I don't wish to use async http, because my requests are done from within a CGI script. Once I start waiting for an async http port, my cgi script finishes and dies before I get the response. I prefer waiting for synchronous http rather than sleep() or have a while loop waiting for a boolean value to be true. I want my CGI script to move straightforward from start to end. don cole wrote: > I hope you mean "when I can do one". Do I have to? Does retrieving content from a web server necessarily involve disk activity? I have to open a port, sure, but I don't have to mess with my disk drive, do I? > I'd like to see a sample of this webpage you are trying to get text from. It could be anything, really. It could be http://www.rapideuphoria.com/. The CGI script reads (will read, hopefully) the webpage into a string and rewrite some of it to be displayed in the client browser. E.g. I could extract whatever is within the <title> tags. Thanks for peeking into this, anyway. HY Prætera censeo Carthaginem esse delendam
11. Re: DLL question
- Posted by don cole <doncole at pacbell.net> Jul 12, 2006
- 709 views
Hallvard Ystad wrote: > > C Bouzy wrote: > > That is why I sent you to the link to Asynchronous HTTP by Thomas Parslow, > > it does exactly what you want. > > ..except that I don't wish to use async http, because my requests are done > from > within a CGI script. Once I start waiting for an async http port, my cgi > script > finishes and dies before I get the response. I prefer waiting for synchronous > http rather than sleep() or have a while loop waiting for a boolean value to > be true. I want my CGI script to move straightforward from start to end. > > > don cole wrote: > > I hope you mean "when I can do one". > > Do I have to? Does retrieving content from a web server necessarily involve > disk activity? I have to open a port, sure, but I don't have to mess with my > disk drive, do I? > No, if all you want to do is open your browser and read the text of the webpage there woulld be no need of disk activity. Except of course the opening and closing of the browser. Now for that, you wouldn't need any euphoria programing at all just a browser. I was under the impression that you wanted to clip some text and save it for later use. > > I'd like to see a sample of this webpage you are trying to get text from. > > It could be anything, really. It could be <a > href="http://www.rapideuphoria.com/">http://www.rapideuphoria.com/</a>. > The CGI script reads (will read, hopefully) the webpage into a string and > rewrite some of > it to be displayed in the client browser. E.g. I could extract whatever is > within the <title> > tags. > > Thanks for peeking into this, anyway. > HY > > Prætera censeo Carthaginem esse delendam Don Cole
12. Re: DLL question
- Posted by C Bouzy <EUCoder at hotmail.com> Jul 12, 2006
- 651 views
Hallvard Ystad wrote: > > ..except that I don't wish to use async http, because my requests are done > from > within a CGI script. Once I start waiting for an async http port, my cgi > script > finishes and dies before I get the response. > What? The fact it is async will not affect what you want to do. I have used this in quite a few apps, and it will do exactly what you want effectively. I have used it with both CGI and PHP scripts with no problem. Isn't all browsers async anyway? I am not seeing what the problem is. ----C Bouzy ----If you continue to do what you have always done, you will get what you have always gotten.----