View Full Version : Download textfiles from Webserver
Hi,
i want to download textfiles from a webserver. to download a textfile you need to select a day, month and year with 3 comboboxes on the webpage.
normaly there is one textfile for each day of the month. for some days there is no file to download.
my question now, is it possible to send that information to the webpage and download all files of a month one by one and save them in a folder sorted by year and month.
byte
TJ_Tigger
11-02-2005, 07:55 AM
my question now, is it possible to send that information to the webpage and download all files of a month one by one and save them in a folder sorted by year and month.
byte
The bigger question is whether or not the web page allows you to construct a URL that contains that information so you can specify it in the download portion of an HTTP action.
http://yoursite.com/downloads/download.php?mm=11&dd=2&yyyy=2005
Then yes it shouldn't be that difficult.
Tigg
hi TJ_Tigger,
yes the page allows that. but if i enter something like this
permanenzen.php4?tid=1&tag_tag=02&tag_mon=01&tag_jahr=2005
it doesn't download the file, but displaying the file in a html format.
is there a command to download, that i can add to the url?
byte
Take a look at this thread, it might help
http://www.indigorose.com/forums/showthread.php?t=10772&highlight=download+dll
TJ_Tigger
11-02-2005, 08:49 AM
Hard to say, can you code something into your site to allow for downloading wihin the URL? Have you tried HTTP.Download to try and download using that URL? Is it an ascii file or binary file? You might be able to use LuaCOM to access the text.
Without knowing the site and how it works it is hard to help with specifics.
Tigg
@Worm
the sourcecode doesn't help me, i need the textfile.
@TJ_Tigger
the page is not my page, so i can't change anything on it.
the page provides textfiles which can be downloaded by selecting a day, mont and year. by clicking on download, it downloads that textfile.
i thought it could be done by passing the varibales. here is the link to that page, maybe you can figure something out.
http://www.spielbank-hamburg.de/spielsaal/permanenzen.php4
byte
TJ_Tigger
11-02-2005, 09:43 AM
Hard to say. I can play with it, but I am not a Web person I have very limited knowledge on HTML and PHP. Have you contacted the owner of the site to see if there is a way for you to script the ability to obtain these files from an external program?
Tigg
Brett
11-02-2005, 09:44 AM
I think what you want to do then is an HTTP.Submit action something like this:
tblValues = {tid="1",tag_tag="02",tag_mon="01",tag_jahr="2005"};
strReturn = HTTP.Submit("http://YOURURL.COM/permanenzen.php4",tblValues,SUBMITWEB_GET);
local nLastError = Application.GetLastError();
if(nLastError == 0)then
-- Everything was successful...
Dialog.Message("Success",strReturn);
-- You can now write strReturn out to a text file if you want...
TextFile.WriteFromString("C:\\Textfile.txt",strReturn);
else
Dialog.Message("Error",_tblErrorMessages[nLastError]);
end
Use the sample app I posted here...
http://www.indigorose.com/forums/showpost.php?p=51549&postcount=2
In the Input Box, use the following as the source to the doc. Take out the _RemoveThis_
_RemoveThis_http://www.spielbank-hamburg.de/spielsaal/permanenzen.php4?tid=1&tag_tag=02&tag_mon=01&tag_jahr=2005&download.x=15&download.y=14
hi worm,
that works perfect. how did you figure that out?
byte
Took a wild guess that the PHP script was looking for a passed parameter from the image you clicked on to determine whether to download, or display the information. When I added "download.x" to the passed parameters, it worked.
I tried using the built in actions of AMS, but I couldn't used "download.x" as a associative name in a table, so it wouldn't work. That doesn't mean its not possible, just I couldn't do it in the 5 minutes I tried, and the DLL worked, so...
hi worm,
if i enter that adress directly into my browser adressfield, it opens the save filebox and asks for the place to save the file and downloads that textfile.
is it possible to do the same thing within AMS without asking where to save the file. instead give a folder in AMS where to save it.
byte
you could try something like this...
tid="1"
tag_tag="02"
tag_mon="11"
tag_jahr="2005"
sTXT = GetUrlSrc("http://www.spielbank-hamburg.de/spielsaal/permanenzen.php4?tid="..tid.."&tag_tag="..tag_tag.."&tag_mon="..tag_mon.."&tag_jahr="..tag_jahr.."&download.x=15&download.y=15");
sTXT = String.Replace(sTXT,"\r", "")
sTXT = String.Replace(sTXT,"\n", "\r\n")
sFolder = Dialog.FolderBrowse("Folder to Save to...", _DesktopFolder)
if sFolder ~= "CANCEL" then
TextFile.WriteFromString(sFolder.."\\"..tag_jahr..tag_mon..tag_tag.."_"..tid..".txt", sTXT, false)
else
Dialog.Message("File Save", "The file was not saved.")
end
thanks for your help,
this is what i did so far. works perfect.
Table_selected = ComboBox.GetSelected("CB_Tisch");
stable = ComboBox.GetItemData("CB_Tisch", Table_selected);
Month_selected = ComboBox.GetSelected("CB_Monat");
smonth = ComboBox.GetItemData("CB_Monat", Month_selected);
tmonth = ComboBox.GetItemText("CB_Monat", Month_selected);
Year_selected = ComboBox.GetSelected("CB_Jahr");
syear = ComboBox.GetItemData("CB_Jahr", Year_selected);
FolderYear = Folder.DoesExist(_SourceFolder.."\\Perm original\\"..syear);
if FolderYear == false then
Folder.Create(_SourceFolder.."\\Perm original\\"..syear);
end
FolderMonth = Folder.DoesExist(_SourceFolder.."\\Perm original\\"..syear.."\\"..tmonth);
if FolderMonth == false then
Folder.Create(_SourceFolder.."\\Perm original\\"..syear.."\\"..tmonth);
end
FolderTable = Folder.DoesExist(_SourceFolder.."\\Perm original\\"..syear.."\\"..tmonth.."\\Tisch "..stable);
if FolderTable == false then
Folder.Create(_SourceFolder.."\\Perm original\\"..syear.."\\"..tmonth.."\\Tisch "..stable);
end
--Progressbar initialisieren
EndProgress = 31;
Progress.SetRange("Status", 0, EndProgress);
Progress.SetCurrentPos("Status", 0);
Progress.SetStep("Status", 1);
Progress.SetVisible("Status", true);
for i = 1, 31, 1 do
Progress.StepIt("Status");
sTXT = GetUrlSrc("http://www.spielbank-hamburg.de/spielsaal/permanenzen.php4?tid="..stable.."&tag_tag="..i.."&tag_mon="..smonth.."&tag_jahr="..syear.."&download.x=15&download.y=14");
sTXT = String.Replace(sTXT,"\r", "");
sTXT = String.Replace(sTXT,"\n", "\r\n");
TextFile.WriteFromString(_SourceFolder.."\\Perm original\\"..syear.."\\"..tmonth.."\\Tisch "..stable.."\\"..syear..smonth.."0"..i.."_"..stable..".txt", sTXT, false);
end
Progress.SetVisible("Status", false);
byte
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.