Jump to content
FaridAgl

UrlDownloadEx() - Download with maximum speed

Recommended Posts

Re-tested today : on 5 tests Combofix was downloaded 4 times, so maybe there are problems on combofix server or my connection.

I think in production script I put on a test to check the "real" presence of the downloaded file on the filesystem.

Thank you for this #include.

Share this post


Link to post
Share on other sites
"D:testsetupUrlDownloadEx + ExamplesUrlDownloadEx.au3"(65,70) : error: 表达式错误 (非法字符)
Local Const $FLAGS = ($avUrlComponents[1] = $INTERNET_SCHEME_HTTPS) ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:testsetupUrlDownloadEx + ExamplesUrlDownloadEx.au3"(203,74) : warning: $FO_CREATEPATH: 使用前并未进行声明.
Local $hFile = FileOpen($sFileName, BitOR($FO_OVERWRITE, $FO_CREATEPATH,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:testsetupUrlDownloadEx + ExamplesExample 1.au3"(4,148) : error: 表达式错误 (非法字符)
Global $vResult = UrlDownloadEx("http://dldir1.qq.com/qqfile/qq/QQ6.1/11905/QQ6.1.exe", @ScriptDir & "QQ6.1.exe", Default, BytesReceived)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:testsetupUrlDownloadEx + ExamplesUrlDownloadEx.au3"(203,74) : error: $FO_CREATEPATH: 未声明的全局变量.
Local $hFile = FileOpen($sFileName, BitOR($FO_OVERWRITE, $FO_CREATEPATH,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:testsetupUrlDownloadEx + ExamplesUrlDownloadEx.au3"(56,31) : error: IsFunc(): 未定义的函数.
If (IsFunc($CallbackFunction)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:testsetupUrlDownloadEx + ExamplesExample 1.au3 - 4 错误, 1 警告
 

 

meet erro.

Share this post


Link to post
Share on other sites

FaridAgl,

Very nice !

Maybe could you make a variant of the famous IDM, but more simple.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

FireFox,
Actually it's possible to write such thing with this, it's even possible to pause the download and resume it later.
Maybe in feature, when I had enough time I started working on your suggestion.
Thanks.

hearton,

I can't read the errors, as they are Chinese (I guess).

But as the problem is with the ternary operator I guess you just have to install the latest AutoIt version.

Share this post


Link to post
Share on other sites

thanks , it is my au3 vertion problem.

but now i meet a new question

http://dldir1.qq.com/qqfile/qq/QQ6.1/11905/QQ6.1.exe

down this file return  erro 9

Result: 0
Size: 0
Error: 9
Timer: 874

 

can you help me?

you can have a try down this file.

change :

"_WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS)" in line 76 and 116 to

"_WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, Default, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS)" 

Edited by DjForfun

Share this post


Link to post
Share on other sites

This udf is ok with most of my cases.

I would like to download tools like this : http://www.nicolascoolman.fr/download/zhpcleaner/

with this link : http://www.nicolascoolman.fr/?wpdmdl=1956

Someone says me to use referer with com object, it is ok.

But is it possible to use _winhttp with referer and download files likes this?

Edited by kaz

Share this post


Link to post
Share on other sites

I searched to make possible to download tools like this.

The function _WinHttpOpenRequest accept a parameter $sReferrer.

i searched for a long time...

i started from this udf

i have to use $avUrlComponents[6] & $avUrlComponents[7] to obtain the correct $OBJECT_NAME

The line Local $sContentRange = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_RANGE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) 

return bytes 0-01225216/1225216

and so the line Local $iDownloadSize = Int(StringTrimLeft($sContentRange, StringLen("bytes 0-0/")), 1) return a strong value

i replace it by Local $iDownloadSize = Int(StringTrimLeft($sContentRange, StringInStr($sContentRange, "/", 0, -1)), 1) to obtain the correct one.

Of course i have to indicate $sreferer.

With this changes, the file is download correctly.

Sorry for my bad english.

Edited by kaz

Share this post


Link to post
Share on other sites

and now, i would like to download HitManPro, it' an other antimalware tool...

These no probleme whith inet.. function but doesn't work with this udf.

apparently, it's a simple link with a file behind : http://dl.surfright.nl/HitmanPro.exe

But it doesn't work, soon peharps...

i prefer download with this udf because the speed is better.

SOLUTION :

the accept type in each _WinHttpOpenRequest... must be change, the default one isn't accept by download server.

Edited by kaz

Share this post


Link to post
Share on other sites
On 29.07.2014 at 12:39 PM, Celtic88 said:

change :

"_WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS)" in line 76 and 116 to

"_WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, Default, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS)" 

This solution does not work for me.

I try with this :

Global $vResult = UrlDownloadEx("http://lipok.pl/AutoIt.Forum/Avatar/Clock_Face.jpg", @ScriptDir & "\Clock_Face.jpg", Default, BytesReceived)

Any sugestion why I get:

Quote

Result:    0
Size:    0
Error:    9
Timer:    180

?

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

I know it's an old thread (well, maybe not so) but maybe someone has an idea about the reason and solution of error number 9 ?


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

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

×
×
  • Create New...