Retrieve file list from web directory
The following explains one method to extract a file list from an online web directory.
n.b. In this lesson we will be retrieving a list from an "on-rev" web directory. There may be slight differences when retrieving the data from different web hosts
Create and Setup new Stack
View intial source of directory
We will want to use the source data of our web directory in order to extract the required data from it. We can view the source data of the following test site by executing the folloiwng script in the message box
put url "http://techsupport.on-rev.com/cloud/VideoAssets/" into field "data"
From the above screen, you can see that the source includes alot of data that we dont need. The next step will cover how to remove this and extract the data that we need
Extracting the data
Add the folloing script to your button-
put url ("http://techsupport.on-rev.com/cloud/VideoAssets/") into tURL
put empty into field "data"
delete line 1 to 8 of tURL
delete line -3 to -1 tURL
set the itemdel to quote
repeat with x = 1 to the number of lines of tURL
put item 6 of line x of tURL into tData
put cr after tData
put tData after field "data"
replace "%20" with space in field "data"
A breakdown of this script is-
1) Aquires the source
2) Clear any existing data from the field
3) Removes any non-needed lines of text
4) We set the item delimiter to quote
5) Set up a repeat look to loop through the lines of the remaining text and place the desired item into field "data". As the item delimiter is quote, then item 6 of each line is the list we need
6) The list will contain "%20" where spaces should be, so replacing these with spaces makes things more aesthetically pleaseing.