1. DLL question

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

new topic     » topic index » view message » categorize

2. Re: DLL question

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.----

new topic     » goto parent     » topic index » view message » categorize

3. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: DLL question

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 }}}

new topic     » goto parent     » topic index » view message » categorize

7. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

8. Re: DLL question

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.----

new topic     » goto parent     » topic index » view message » categorize

9. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

11. Re: DLL question

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

new topic     » goto parent     » topic index » view message » categorize

12. Re: DLL question

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.----

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu