Pour faire simple : je me créai des scripts qui me permette de télécharger les applications installées sur mon PC...
Du style : 7zip, Agent Ransack, etc...
Et je me sers de deux méthodes pour récupérer le lien direct du fichier en question :
- En récupérant le code source.
- En utilisant les fonctions _IE (_IECreate & _IELinkGetCollection)
J'y arrive....
Mais il y a qu'un seul fichier dont je n'arrive pas à télécharger via un script...
Et... c'est : le fichier pack débutant FR de notre chef (^^)
=> https://www.autoitscript.fr/forum/viewtopic.php?t=2571
=> et donc : https://www.autoitscript.fr/download/in ... AutoIt-Fr/
Parlons de 7Zip :
1. Je le télécharge avec ce script (en récupérant le lien via le code source) :
#include <Inet.au3>
$Destination = @DesktopDir & "\Mes programmes"
$lien = "http://www.7-zip.org/download.html"
$cs = "codesource.txt"
$cst = FileOpen($cs,2)
FileWrite($cst,_INetGetSource($lien))
FileClose($cst)
For $a = _FileCountLines($cs) to 1 step -1
If StringInStr(FileReadLine($cs,$a),'-x64.exe') then $7zip_x64 = FileReadLine($cs,$a)
If StringInStr(FileReadLine($cs,$a),'.exe') and not StringInStr(FileReadLine($cs,$a),'-x64.exe') then $7zip_x86 = FileReadLine($cs,$a)
Next
if @OSArch = "X86" then $7zip_exe = 'http://www.7-zip.org/'& _FindBetweenString($7zip_x86, '<A href="', '">Download')
If @OSArch <> "X86" then $7zip_exe = 'http://www.7-zip.org/'& _FindBetweenString($7zip_x64, '<A href="', '">Download')
$Fichier_7zip_T = @TempDir & "\7zip_inst.exe"
$Fichier_7zip = $Destination & "\7zip_inst.exe"
$myDL = InetGet($7zip_exe, $Fichier_7zip_T, 1, 1)
Do
Sleep(250)
Until InetGetInfo($myDL, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($myDL, 0)
InetClose($myDL) ; Close the handle to release resources.
If FileExists($Fichier_7zip_T) Then
DirCreate($Destination)
FileMove($Fichier_7zip_T, $Fichier_7zip, 1)
EndIf
FileDelete($cs)
ShellExecute($Destination)
Func _FindBetweenString($Line, $char1, $char2)
$part1 = StringRegExpReplace($Line, "^.*" & $char1, "")
$Term = StringRegExpReplace($part1, "\" & $char2 & ".*", "")
Return SetExtended(1, $Term)
EndFunc ;==>Fonction crée _FindBetweenString
#include <Inet.au3>
$Destination = @DesktopDir & "\Mes programmes"
$lien = "http://www.7-zip.org/download.html"
$oIE = _IECreate($lien, 1, 0)
$oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
While 1
For $oLink In $oLinks
If @OSArch <> "X86" Then
If StringInStr($oLink.href, "-x64.exe") Then
$7zip_exe = $oLink.href
ExitLoop
EndIf
Else
If Not StringInStr($oLink.href, "-x64.exe") And StringInStr($oLink.href, ".exe") Then
$7zip_exe = $oLink.href
ExitLoop
EndIf
EndIf
Next
ExitLoop
WEnd
$Fichier_7zip_T = @TempDir & "\7zip_inst.exe"
$Fichier_7zip = $Destination & "\7zip_inst.exe"
$myDL = InetGet($7zip_exe, $Fichier_7zip_T, 1, 1)
Do
Sleep(250)
Until InetGetInfo($myDL, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($myDL, 0)
InetClose($myDL) ; Close the handle to release resources.
If FileExists($Fichier_7zip_T) Then
DirCreate($Destination)
FileMove($Fichier_7zip_T, $Fichier_7zip, 1)
EndIf
ShellExecute($Destination)
Par contre, j'utilise la méthode avec les fonctions _IE.
Malgré que je récupère bien le bon lien : impossible de le télécharger, comme je le fais avec 7zip
#include <File.au3>
#include <Inet.au3>
$Destination = @DesktopDir & "\Mes programmes"
$lien = "https://www.autoitscript.fr/download/download/AutoIt_Addon/Pack_AutoIt-Fr/"
$oIE = _IECreate($lien, 1, 0)
$oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
For $oLink In $oLinks
If StringInStr($oLink.href, ".exe") Then $AutoIt_tlem_exe = $oLink.href
Next
$Fichier_AutoitTlem_T = @TempDir & "\AutoitTlem_inst.exe"
$Fichier_AutoitTlem = $Destination & "\AutoitTlem_inst.exe"
$myDL = InetGet($AutoIt_tlem_exe, $Fichier_AutoitTlem_T, 1, 1)
Do
Sleep(250)
Until InetGetInfo($myDL, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($myDL, 0)
InetClose($myDL) ; Close the handle to release resources.
If FileExists($Fichier_AutoitTlem_T) Then
DirCreate($Destination)
FileMove($Fichier_AutoitTlem_T, $Fichier_AutoitTlem, 1)
EndIf
If FileExists($Destination) then ShellExecute($Destination)
Pouvez-vous m'aider à éclaircir ce souci ?
Ou alors, existe-t-il une protection contre ce type de téléchargement ?
Car si c'est le cas, autant me le dire, et le signaler pour les futures personnes
++