Hello folks!
Some problem here. Let's say I have a link like this:
http://sberbank-ast.ru/Download.aspx?fi ... 150b4aca4a
(link is clickable, and a real file is there)
Downloading is not possible before I click download button on page or run .js (worse way as there would be different file extensions). Using AHK built-in tools for download would just get that page itself. Is there some way to use AHK for automatic downloading files from such links?
Downloading from complicated page Topic is solved
Downloading from complicated page
Твой софт - говно!
Re: Downloading from complicated page
I'm not sure about using AutoHotkey by itself, but you might be able to scrape the information required from the HTML and pass it to cURL:
http://www.confusedbycode.com/curl/#downloads
If you were able to provide a link to several more files it would make it easier to help build this.
Code: Select all
curl "http://sberbank-ast.ru/Download.aspx?fid=94c36df6-ece6-4993-971a-72150b4aca4a" -H "Host: sberbank-ast.ru" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Referer: http://sberbank-ast.ru/Download.aspx?fid=94c36df6-ece6-4993-971a-72150b4aca4a" -H "Cookie: _sm_au_c=iVVSL6R80rMj0TS70f; ASP.NET_SessionId=e0gsbnasaw52hofbs30cq2pt" -H "DNT: 1" -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" -o File.zip --data "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE="%"2FwEPDwULLTE4NjAzMjc1MzIPZBYCZg9kFgICAw9kFgQCAQ8PFgIeB1Zpc2libGVoZGQCAg9kFgQCAw9kFgICAw9kFgICAg8PFgIfAGdkFgICAg8WAh4EVGV4dAVAICjQoNCw0LfQvNC10YA6ICAxOTkgNTU2INCx0LDQudGCOyDQt9Cw0LPRgNGD0LbQtdC9OiAxMy4wNy4yMDE2KWQCBQ8WAh8AaGRkW7YZoZFgkfcLOwS2bYeLoSfOjiY"%"3D&ctl00"%"24xmlData=&ctl00"%"24phDataZone"%"24btnSaveAsFile="%"D0"%"92"%"D1"%"8B"%"D0"%"B3"%"D1"%"80"%"D1"%"83"%"D0"%"B7"%"D0"%"B8"%"D1"%"82"%"D1"%"8C+"%"D0"%"BA"%"D0"%"B0"%"D0"%"BA+"%"D1"%"84"%"D0"%"B0"%"D0"%"B9"%"D0"%"BB"
If you were able to provide a link to several more files it would make it easier to help build this.
Re: Downloading from complicated page
TheDewd, thank you very much for trying!
Here some another similar links:
http://www.sberbank-ast.ru/Download.asp ... b4faaabb02
http://www.sberbank-ast.ru/Download.asp ... 27D7D565E0
http://www.sberbank-ast.ru/Download.asp ... 831F820756
http://www.sberbank-ast.ru/Download.asp ... 99978b6ecd
Here some another similar links:
http://www.sberbank-ast.ru/Download.asp ... b4faaabb02
http://www.sberbank-ast.ru/Download.asp ... 27D7D565E0
http://www.sberbank-ast.ru/Download.asp ... 831F820756
http://www.sberbank-ast.ru/Download.asp ... 99978b6ecd
Твой софт - говно!
Re: Downloading from complicated page Topic is solved
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
URL := "http://sberbank-ast.ru/Download.aspx?fid=94c36df6-ece6-4993-971a-72150b4aca4a"
Gui, Add, ActiveX, w600 h300 vwb, Shell.Explorer
Gui, Show
ComObjConnect(wb, "wb_")
wb.navigate(URL)
while WB.ReadyState != 4
Sleep 100
wb.document.getElementById("phDataZone_FileGeneralData1_lbDownload").click()
return
GuiClose:
ExitApp
wb_BeforeNavigate2(pDisp, url, Flags, TargetFrameName, PostData, Headers, Cancel) {
if PostData {
Cancel[] := true
pDisp.document.open()
pDisp.document.write("Downloading...")
XMLHTTP_Download(url, "download_test.pdf", PostData, Headers)
pDisp.document.open()
pDisp.document.write("Download Finished! Saved to download_test.pdf")
}
}
XMLHTTP_Download(URL, Filename:="", PostData:="", Headers:="") {
static req := ComObjCreate("Msxml2.XMLHTTP")
req.open(PostData ? "POST" : "GET", URL, true)
Loop, Parse, Headers, `n, `r
{
if RegExMatch(A_LoopField, "(.+?)\s*:\s*(.+)", m)
req.SetRequestHeader(m1, m2)
}
req.send(PostData)
while req.readyState != 4
sleep 100
if (req.status == 200 || req.status == 304) {
if (Filename = "") {
if !RegExMatch( req.getResponseHeader("Content-Disposition"), "filename=\K.+", Filename )
Filename := A_Now ".XMLHTTP_Download"
}
ADO := ComObjCreate("ADODB.Stream")
ADO.Type := 1 ; adTypeBinary
ADO.Open()
ADO.Write(req.responseBody)
ADO.SaveToFile(FileName, 2)
ADO.Close()
} else {
throw, "Status " req.status
}
}
However the better way to do this task, is to extract the post data from the HTML source, then POST directly.
Re: Downloading from complicated page
tmplinshi, wow, you are truly an almighty wizard! Just one small question: is it possible to do the same without any gui?
Твой софт - говно!
Re: Downloading from complicated page
This approach require GUI, but you can delete Gui, Show to not show GUI.
Who is online
Users browsing this forum: Spawnova and 256 guests