Author Topic: Download file from internet  (Read 7691 times)

0 Members and 1 Guest are viewing this topic.

TopoWAR

  • Newt
  • Posts: 135
Download file from internet
« on: October 06, 2011, 12:49:57 PM »
Hi Everyone! Is there any way to download a file online? for example, "http://www.opendcl.com/version/version.txt"
thanks
Thanks for help

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Download file from internet
« Reply #1 on: October 06, 2011, 12:53:16 PM »
See here and here.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Download file from internet
« Reply #2 on: October 06, 2011, 01:04:27 PM »
you don't have to save the file just to know the odcl's version
Code: [Select]
(defun vk_GetRemoteText (RemoteFileName / objHTTP Result)
    (if (setq objHTTP (vlax-create-object "WinHTTP.WinHTTPRequest.5.1"))
        (progn (setq
                   Result (vl-catch-all-apply
                              (function
                                  (lambda ()
                                      (vlax-invoke-method
                                          objHTTP       "Open"
                                          "GET"         RemoteFileName
                                          :vlax-false
                                         )
                                      (vlax-invoke objHTTP "Send")
                                      (vlax-get-property objHTTP "ResponseText")
                                  )
                              )
                          )
               )
               (vlax-release-object objHTTP)
               (if (not (vl-catch-all-error-p Result))
                   Result
               )
        )
    )
)
;;;(vk_GetRemoteText "http://www.opendcl.com/version/version.txt")

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Download file from internet
« Reply #3 on: October 06, 2011, 01:21:55 PM »
you don't have to save the file just to know the odcl's version
wow  :kewl:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Download file from internet
« Reply #4 on: October 06, 2011, 01:24:35 PM »
That is cool  8-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Download file from internet
« Reply #5 on: October 06, 2011, 01:27:49 PM »
you don't have to save the file just to know the odcl's version

Not sure if this applies to the WinHTTP Object, but here I found the XMLHTTP Object seemed to cache the result when using the "GET" keyword, so you may want to use the "POST" operator.

Lee

TopoWAR

  • Newt
  • Posts: 135
Re: Download file from internet
« Reply #6 on: October 06, 2011, 02:14:17 PM »
by teachers, great code!! :lol:
Thanks for help

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Download file from internet
« Reply #7 on: October 06, 2011, 05:01:27 PM »
i share with pleasure, thanks


Not sure if this applies to the WinHTTP Object, but here I found the XMLHTTP Object seemed to cache the result when using the "GET" keyword, so you may want to use the "POST" operator.
Lee
i can't say anything for sure, know nothing about http
i've just googled this http://www.cs.tut.fi/~jkorpela/forms/methods.html
there is a paragraph about "caching" but as i've understood it's about cahing a request on a server not a local file

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Download file from internet
« Reply #8 on: October 06, 2011, 05:53:41 PM »
Not sure if this applies to the WinHTTP Object, but here I found the XMLHTTP Object seemed to cache the result when using the "GET" keyword, so you may want to use the "POST" operator.
Lee
i can't say anything for sure, know nothing about http
i've just googled this http://www.cs.tut.fi/~jkorpela/forms/methods.html
there is a paragraph about "caching" but as i've understood it's about cahing a request on a server not a local file

That's an interesting link, I shall have to take some time to read it more thoroughly.

I remember reading the following from here:
Quote from: MSDN
Internet Explorer caches the results of HTTP GET requests in the Temporary Internet Files (TIF) folder. In most cases, caching improves performance for data that will not change frequently. To guarantee that the results are not cached, use POST.

I noticed this caching when testing my Internet Time function, so thought I'd make you aware of the possibility.

At least, if a similar issue arises in the future you will know what to do :-)

Harrie

  • Guest
Re: Download file from internet
« Reply #9 on: October 07, 2011, 04:53:21 AM »
Hi Everyone! Is there any way to download a file online? for example, "http://www.opendcl.com/version/version.txt"
thanks
I know there was a topic to download the BBC news and the BCC weather forecast into the drawing,
but I can’t find it.

Lee your Internet Time function, is this giving the current internet date and time?
« Last Edit: October 07, 2011, 07:38:55 AM by Harrie »

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Download file from internet
« Reply #10 on: October 07, 2011, 07:09:03 AM »
Hi Everyone! Is there any way to download a file online? for example, "http://www.opendcl.com/version/version.txt"
thanks
I know there was a topic to download the BBC news and the BCC weather forecast into the drawing,
but I can’t find it.

http://www.theswamp.org/index.php?topic=37107

 :-)

TopoWAR

  • Newt
  • Posts: 135
Re: Download file from internet
« Reply #11 on: October 07, 2011, 10:15:58 AM »
code only works for text files, is this true ?
Is there some code that works for example with jpg or rar ?
Thanks for help

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Download file from internet
« Reply #12 on: October 07, 2011, 10:25:03 AM »
code only works for text files, is this true ?
Is there some code that works for example with jpg or rar ?

See my earlier links above.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Download file from internet
« Reply #13 on: October 07, 2011, 12:22:54 PM »
code only works for text files, is this true ?
true, what do you expect from function named "vk_GetRemoteText"? :)

Harrie

  • Guest
Re: Download file from internet
« Reply #14 on: October 09, 2011, 03:53:29 PM »
Hi Everyone! Is there any way to download a file online? for example, "http://www.opendcl.com/version/version.txt"
thanks
I know there was a topic to download the BBC news and the BCC weather forecast into the drawing,
but I can’t find it.

http://www.theswamp.org/index.php?topic=37107

 :-)
Thanks Lee,

Your Internet Time function, is this giving the current internet date and time?