Sign in to follow this  
Followers 0
mattw112

Download file from website

8 posts in this topic

There's a website that is secure, I log on with username and password.

Then there's a bunch of links to documents.

Some are direct links: http://www.example.com/file.wmv

And some aren't: http://www.example.com/modules/common/downloaddocument.ashx?ObjectType=Topic&DocumentID=e09f5e39-2a56-e011-b0e1-001cc496d8ee

In my code I am able to get the file names ($Filename) from the IE window and I'm able to get the URLs ($URL). Then I run the bit of code below:

Local $hDownload = InetGet($URL, $LastFolder & "\" & $FileName, 1, 1)
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    Local $nBytes = InetGetInfo($hDownload, 0)
    InetClose($hDownload)

All the direct files download ok. in the right spot with the right file names.

None of the non-direct ones do. instead I only get 8K files with the correct file names.

Is there some other command or code I could run to download the non-direct files?

I searched the forum and found WinHttp.au3, but I'm unsure if that'll help me. The code also is a little challenging to figure out. For my situation.

Any help would be great!

Thanks,

Terry

Share this post


Link to post
Share on other sites



You can try automating WGet.

Share this post


Link to post
Share on other sites

You can try automating WGet.

Interesting. Do you have an examples? Have you used before? Do you know if it supports non-direct links?

I'll download and give it a try.

Thanks,

Terry

Share this post


Link to post
Share on other sites

All of the above actually, the below code downloads Firefox 4:

ShellExecute(@ScriptDir&"\wget.exe",' "http://download.mozilla.org/?product=firefox-4.0&os=win&lang=en-US"')

Share this post


Link to post
Share on other sites

Can you help me to download exe file from share point. Will wget.exe help me to download from share point. Share point has username and password too.


------------------------------------------------------"You are never a loser,until you quit trying"------------------------------------------------------

Share this post


Link to post
Share on other sites

All of the above actually, the below code downloads Firefox 4:

ShellExecute(@ScriptDir&"\wget.exe",' "http://download.mozilla.org/?product=firefox-4.0&os=win&lang=en-US"')

Your example worked, but it did not work for one of my urls.

I tried:

;$url = "http://download.mozilla.org/?product=firefox-4.0&os=win&lang=en-US"
$url = "http://www.website.com/modules/common/downloaddocument.ashx?ObjectType=Topic&DocumentID=83d6491e-fd56-e011-b0e1-001cc496d8ee"
ShellExecute(@ScriptDir & "\wget.exe", $url)

Instead of the file I wanted I got a file called:

default.aspx@ReturnUrl=%2Fmodules%2Fcommon%2Fdownloaddocument.ashx%3FObjectType=Topic&DocumentID=83d6491e-fd56-e011-b0e1-001cc496d8ee&ObjectType=Topic&DocumentID=83d6491e-fd56-e011-b0e1-001cc496d8ee

Also I looked through the help but I'm not really seeing the command that I use to specify the directory to download to and how to specify a file name?

Terry

Share this post


Link to post
Share on other sites

hi mattw112,

For help on the usage of Wget (and parameters like output file/directory,login cookies), check their manual. Also, a great deal of debugging (the login process, server side logic, link retrieval) is solely up to you, since you posted very little code, and you seem to be working with an exclusive/private site to which general users of the forum have no access.

-smartee

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

hi mattw112,

For help on the usage of Wget (and parameters like output file/directory,login cookies), check their manual. Also, a great deal of debugging (the login process, server side logic, link retrieval) is solely up to you, since you posted very little code, and you seem to be working with an exclusive/private site to which general users of the forum have no access.

-smartee

Yes you are correct very little code, because that's all there is.. just testing at this point to get an understanding of what was suggested to try to see if it will really work for me.

The real website is a private website so you are correct you wont be able to try it yourself. however I'm trying to make my questions such that someone who has an understanding of my problem could still answer.

I have read what I can and still have questions. What is different about my link (that you can see in the code) to the example link that does work?

I can't be the first one with these sorts of links on a webpage that wants to download them?

If I click on the link it works just fine and asks me where I want to save the file, not sure why I can't automated that.

Thanks,

Terry

Edited by mattw112

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0