xeshan Posted December 15, 2010 Share Posted December 15, 2010 Hello, I am attempting to save pdf files from a work website. I know inetget allows to save a specific file from a website, but is it possible to specify a file 'type' instead of the specific file name? In other words, ; Advanced example - downloading in the background Local $hDownload = InetGet("http://myworksite/folder/dir", @TempDir & "\*.pdf", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ; Close the handle to release resourcs. MsgBox(0, "", "Bytes read: " & $nBytes) Is something like this possible? Please let me know, Thank you Gurus! Link to comment Share on other sites More sharing options...
wakillon Posted December 15, 2010 Share Posted December 15, 2010 (edited) No, you must list all pdf and download them one by one... Edited December 15, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
spudw2k Posted December 15, 2010 Share Posted December 15, 2010 (edited) I've built such a script myself recently to accommodate this same task. Lemme look for it.edit: Here's the script. You'll have to tailor it to your needs, but this should put you in the right direction with a running start.edit:I also must mention that I arbitrarily did a StringRight to trim the file names, but this only worked because all the files had the same length of chars. You'll have to decide how to name the saved files.#include <IE.au3> $oIE = _IECreate("archive.wmlnj.org/TheWeatherVane/1973/") $oLinks = _IELinkGetCollection ($oIE) If @error Then msgbox(0,"Failed To Navigate to Webpage","") Exit EndIf $savedir = FileSelectFolder("Save PDFs To","",5,@ScriptDir) If Not $savedir Then Exit For $oLink In $oLinks If StringInstr($oLink.href,".pdf") Then ConsoleWrite(InetGet($oLink.href,$savedir & "\" & StringRight($oLink.href,11))&@CRLF) EndIf Next msgbox(0,"Done","") Edited December 15, 2010 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
xeshan Posted December 17, 2010 Author Share Posted December 17, 2010 Thank you spudw2k! I modified your script slightly if it may be of help for some other users. Thank you again. #include <IE.au3> $oIE = _IECreate("archive.wmlnj.org/TheWeatherVane/1973/") $oLinks = _IELinkGetCollection ($oIE) If @error Then msgbox(0,"Failed To Navigate to Webpage","") Exit EndIf $savedir = FileSelectFolder("Save PDFs To","",5,@ScriptDir) If Not $savedir Then Exit For $oLink In $oLinks If StringInstr($oLink.href,".pdf") Then ConsoleWrite(InetGet($oLink.href,$savedir & "\" & _GetFullNameByUrl ( $oLink.href ), 1, 0)) StringRight($oLink.href,11) EndIf Next msgbox(0,"Done","") Func _GetFullNameByUrl ( $_FileUrl ) $_FileName = StringSplit ( $_FileUrl, '/' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetFullNameByUrl ( ) Link to comment Share on other sites More sharing options...
spudw2k Posted January 11, 2011 Share Posted January 11, 2011 (edited) I updated my script and made it more versatile. It also provides useful visual feedback as it runs. Still could use some optimizing and cleanup. edit: Whoops, wrote in an older version which didn't support @Inet macros. Updated to 3.3.6.1 expandcollapse popup#include <IE.au3> $url = InputBox("URL to download from?","","archive.wmlnj.org/TheWeatherVane/1973/") $linktype = InputBox("Links to download?","What type of links?",".PDF") ProgressOn("Navigating to URL","Finding Links") $oIE = _IECreate($url,0,0) If @error Then msgbox(0,"Failed To Navigate to Webpage","") Exit EndIf $oLinks = _IELinkGetCollection ($oIE) Dim $arrLinks[1] $arrIdx = 0 For $oLink In $oLinks If StringInstr($oLink.href,$linktype) Then ReDim $arrLinks[UBound($arrLinks)+1] $arrIdx+=1 $arrLinks[$arrIdx]=$oLink.href EndIf Next $arrLinks[0]=UBound($arrLinks) _IEQuit($oIE) ProgressOff() If UBound($arrLinks)<=1 Then msgbox(0,"No " & $linktype & " links found.","") Exit EndIf $savedir = FileSelectFolder("Save Links to","",1,@ScriptDir) If Not $savedir Then Exit ProgressOn("Downloading Links","") For $i = 1 to $arrLinks[0] $size = Int(InetGetSize($arrLinks[$i])/1024) ProgressSet(0,"","Downloading " & $i & " of " & $arrLinks[0]) $savefile = StringTrimLeft($arrLinks[$i],StringInstr($arrLinks[$i],"/",0,-1)) $hDownload = InetGet($arrLinks[$i],$savedir & "\" & $savefile,1,1) Do sleep(250) $data = Int(InetGetInfo($hDownload,0)/1024) ProgressSet(($data/$size)*100,$savefile & @CRLF & $data & "KB of " & $size & "KB","Downloading " & $i & " of " & $arrLinks[0]) Until InetGetInfo($hDownload,2) Next msgbox(0,"Done","") Edited January 11, 2011 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now