[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Download file from https://...

Tim Rude

4/1/2012 9:26:00 PM

I've played with Karl Peterson's NetGrab code
(http://vb.mvps.org/sample...) which uses the AsynRead properties of
a user control to download files. Very slick!

However, I can't get it to download a page from an HTTPS:// server. It fails
with system error &H80072F7E.

Here's an example of a web page that I want to be able to download (url
should be all on one line):

https://tools.usps.com/go/ZipLookupRes...!input.action?resultMode=0&companyName=&address1=1600+Amphitheatre+Parkway&address2=&city=Mountain+View&state=CA&urbanCode=&postalCode=&zip=

This is a USPS address/zipcode lookup result page.

Anybody know how download a page from an https:// server?

32 Answers

Karl E. Peterson

4/3/2012 12:45:00 AM

0

on 4/1/2012, Tim Rude supposed :
> I've played with Karl Peterson's NetGrab code
> (http://vb.mvps.org/sample...) which uses the AsynRead properties of a
> user control to download files. Very slick!
>
> However, I can't get it to download a page from an HTTPS:// server. It fails
> with system error &H80072F7E.
>
> Here's an example of a web page that I want to be able to download (url
> should be all on one line):
>
> https://tools.usps.com/go/ZipLookupRes...!input.action?resultMode=0&companyName=&address1=1600+Amphitheatre+Parkway&address2=&city=Mountain+View&state=CA&urbanCode=&postalCode=&zip=
>
> This is a USPS address/zipcode lookup result page.
>
> Anybody know how download a page from an https:// server?

Yeah, unfortunately, I don't think there's anyway to do that with
what's built into UserControls. I would guess you'll need/want to go
straight to wininet...

http://visualbasic.about.com/od/quicktips/qt/vb...

Or pick up someone else's wrapper...

http://www.dart.com/ct...

(Both links just quick examples. Didn't spend any time evaluating.)

--
..NET: It's About Trust!
http://vfre...


Tim Rude

4/3/2012 1:30:00 PM

0

"Karl E. Peterson" <karl@exmvps.org> wrote in message
news:jldh5t$d3s$1@dont-email.me...
> on 4/1/2012, Tim Rude supposed :
>> I've played with Karl Peterson's NetGrab code
>> (http://vb.mvps.org/sample...) which uses the AsynRead properties
>> of a user control to download files. Very slick!
>>
>> However, I can't get it to download a page from an HTTPS:// server. It
>> fails with system error &H80072F7E.
>>
>> Here's an example of a web page that I want to be able to download (url
>> should be all on one line):
>>
>> https://tools.usps.com/go/ZipLookupRes...!input.action?resultMode=0&companyName=&address1=1600+Amphitheatre+Parkway&address2=&city=Mountain+View&state=CA&urbanCode=&postalCode=&zip=
>>
>> This is a USPS address/zipcode lookup result page.
>>
>> Anybody know how download a page from an https:// server?
>
> Yeah, unfortunately, I don't think there's anyway to do that with what's
> built into UserControls. I would guess you'll need/want to go straight to
> wininet...
>
> http://visualbasic.about.com/od/quicktips/qt/vb...
>
> Or pick up someone else's wrapper...
>
> http://www.dart.com/ct...
>
> (Both links just quick examples. Didn't spend any time evaluating.)
>
> --
> .NET: It's About Trust!
> http://vfre...
>

Karl,

Yeah, it's a shame the UserControls method won't work with SSL connections.

I came across the following snippet which uses the URLDownloadToFile API
call, and it worked to download the USPS page via SSL:
http://www.devx.com/vb2themax...

Any thoughts on this method?

Tim Rude

Mayayana

4/3/2012 2:11:00 PM

0


| I came across the following snippet which uses the URLDownloadToFile API
| call, and it worked to download the USPS page via SSL:
| http://www.devx.com/vb2themax...
|

That might make sense. It's really just an IE wrapper,
so it's taking care of the nitty gritty. Though depending
on your IE security settings, and the server certificate,
you might also see a message asking about whether to
accept the certificate, for the same reason: You're
really just automating IE.

I don't know much about SSL, but there's a rundown here:

http://en.wikipedia.org/wiki/Transport_Laye...

Based on that it looks like you could implement it but
you'd need to write code to deal with certificate checking
and you'd probably need to use capicom.dll for encryption.
And of course you need to handle the server "handshake"
and conversation.

I tried your URL with code that I wrote myself -- basic
download code that uses winsock and carries out the server
conversation directly, but assumes http. I got a 302
response from the server. (Moved temporarily.) The moved
to URL was the https version. I guess that makes sense,
though I think that some servers can accomodate an http
version of an https URL.


Karl E. Peterson

4/3/2012 5:35:00 PM

0

Tim Rude brought next idea :
> "Karl E. Peterson" <karl@exmvps.org> wrote in message
> news:jldh5t$d3s$1@dont-email.me...
>> on 4/1/2012, Tim Rude supposed :
>>> I've played with Karl Peterson's NetGrab code
>>> (http://vb.mvps.org/sample...) which uses the AsynRead properties
>>> of a user control to download files. Very slick!
>>>
>>> However, I can't get it to download a page from an HTTPS:// server. It
>>> fails with system error &H80072F7E.
>>>
>>> Here's an example of a web page that I want to be able to download (url
>>> should be all on one line):
>>>
>>> https://tools.usps.com/go/ZipLookupRes...!input.action?resultMode=0&companyName=&address1=1600+Amphitheatre+Parkway&address2=&city=Mountain+View&state=CA&urbanCode=&postalCode=&zip=
>>>
>>> This is a USPS address/zipcode lookup result page.
>>>
>>> Anybody know how download a page from an https:// server?
>>
>> Yeah, unfortunately, I don't think there's anyway to do that with what's
>> built into UserControls. I would guess you'll need/want to go straight to
>> wininet...
>>
>> http://visualbasic.about.com/od/quicktips/qt/vb...
>>
>> Or pick up someone else's wrapper...
>>
>> http://www.dart.com/ct...
>>
>> (Both links just quick examples. Didn't spend any time evaluating.)
>
> Yeah, it's a shame the UserControls method won't work with SSL connections.
>
> I came across the following snippet which uses the URLDownloadToFile API
> call, and it worked to download the USPS page via SSL:
> http://www.devx.com/vb2themax...
>
> Any thoughts on this method?

I've used it before, but not much so I can't really offer a lot, no.
Maya's warning about IE's security fetishes might be applicable, if
you're doing this for distribution.

--
..NET: It's About Trust!
http://vfre...


unknown

4/4/2012 1:27:00 AM

0

"Tim Rude" <timrude.nospam@nospam.hotmail.com> wrote in message
news:jleu13$c4i$1@dont-email.me...
> Karl,
>
> Yeah, it's a shame the UserControls method won't work with SSL
> connections.
>
> I came across the following snippet which uses the URLDownloadToFile API
> call, and it worked to download the USPS page via SSL:
> http://www.devx.com/vb2themax...
>
> Any thoughts on this method?

That API function would use the cache if the file is already there. If you
don't want that, see this page which shows how to delete the cache entry
first. I am not sure how this works with text shown on a web page instead of
downloading a file:

http://vbnet.mvps.org/code/internet/urldownloadtofilen...

This site is for VB Classic despite it's name which was in use before .Net
was introduced.


Tim Rude

4/4/2012 2:09:00 AM

0

"Farnsworth" <nospam@nospam.com> wrote in message
news:jlg81t$e8q$1@speranza.aioe.org...
> "Tim Rude" <timrude.nospam@nospam.hotmail.com> wrote in message
> news:jleu13$c4i$1@dont-email.me...
>> Karl,
>>
>> Yeah, it's a shame the UserControls method won't work with SSL
>> connections.
>>
>> I came across the following snippet which uses the URLDownloadToFile API
>> call, and it worked to download the USPS page via SSL:
>> http://www.devx.com/vb2themax...
>>
>> Any thoughts on this method?
>
> That API function would use the cache if the file is already there. If you
> don't want that, see this page which shows how to delete the cache entry
> first. I am not sure how this works with text shown on a web page instead
> of downloading a file:
>
> http://vbnet.mvps.org/code/internet/urldownloadtofilen...
>
> This site is for VB Classic despite it's name which was in use before .Net
> was introduced.
>

Oooh, a Randy Birch link! I shoulda already looked there. Nice. :)

Thanks.

ObiWan

4/4/2012 11:08:00 AM

0


> > However, I can't get it to download a page from an HTTPS:// server.
> > It fails with system error &H80072F7E.

> Yeah, unfortunately, I don't think there's anyway to do that with
> what's built into UserControls. I would guess you'll need/want to go
> straight to wininet...

Karl, the error code translates to

# as an HRESULT: Severity: FAILURE (1), Facility: 0x7, Code 0x2f7e
# for hex 0x2f7e / decimal 12158 :
ERROR_INTERNET_UNABLE_TO_CACHE_FILE inetmsg.h
ERROR_INTERNET_UNABLE_TO_CACHE_FILE wininet.h
# 2 matches found for "0x80072F7E"

which seems to indicate that the code is working but has problems since
when downloading the file it apparently also tries to cache it and
that fails (don't ask me why - maybe you'll have some idea)

as a note, when it comes to such errors a quick way to decode them is
to pick this tool from Microsoft

http://www.microsoft.com/download/en/details.a...

notice that it isn't just for exchange (lists a whole bunch of errors
from a ton of locations), it doesn't need to have an installed exchange
and it runs w/o problems on vista/seven/2008 :D the downloadable file
is a self extracting critter, just run it, extract the tool wherever
you want and... use if (from cmdline); no setup or DLLs or stuff ;-)




ObiWan

4/4/2012 11:11:00 AM

0

> notice that it isn't just for exchange (lists a whole bunch of errors
> from a ton of locations)

just run err.exe w/o parameters to see the list of headers used to
compile the error list ;)

Dee Earley

4/4/2012 12:28:00 PM

0

On 04/04/2012 12:07, ObiWan wrote:
> as a note, when it comes to such errors a quick way to decode them is
> to pick this tool from Microsoft
>
> http://www.microsoft.com/download/en/details.a...

Ohh, that's useful! It berats the VS errlookup utility.


--
Deanna Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Dee Earley

4/4/2012 1:31:00 PM

0

On 04/04/2012 13:27, Deanna Earley wrote:
> On 04/04/2012 12:07, ObiWan wrote:
>> as a note, when it comes to such errors a quick way to decode them is
>> to pick this tool from Microsoft
>>
>> http://www.microsoft.com/download/en/details.a...
>
> Ohh, that's useful! It berats the VS errlookup utility.

And Thunderbirds spell checker apparently...

--
Deanna Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)