473,382 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Automatically save images from image URLs

I have inherited a database driven website that comes with a table of image
links. The images are scattered all of the internet and there are thousands
of them. I would like to write an asp script to just run through the table
and download every link by it's URL. I thought I had id by faking a form
with the "File" element and loading it with all the URLs. Would have worked
except you cannot preload the "File" element. As I understand it, with the
"File" element you aren't actually loading the file name into it but the
actual file.

Anyway, seems to me this should be possible.

Thanks for any help/
Dec 11 '07 #1
2 2986
Simon Wigzell wrote on 11 dec 2007 in
microsoft.public.inetserver.asp.general:
I have inherited a database driven website that comes with a table of
image links. The images are scattered all of the internet and there
are thousands of them. I would like to write an asp script to just run
through the table and download every link by it's URL. I thought I had
id by faking a form with the "File" element and loading it with all
the URLs. Would have worked except you cannot preload the "File"
element. As I understand it, with the "File" element you aren't
actually loading the file name into it but the actual file.
You could this clientside,
and have the server only give the client a list img addresses.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 11 '07 #2
"Simon Wigzell" <si**********@shaw.cawrote in message
news:X2A7j.947$ox1.719@pd7urf3no...
I have inherited a database driven website that comes with a table of
image
links. The images are scattered all of the internet and there are
thousands
of them. I would like to write an asp script to just run through the table
and download every link by it's URL. I thought I had id by faking a form
with the "File" element and loading it with all the URLs. Would have
worked
except you cannot preload the "File" element. As I understand it, with the
"File" element you aren't actually loading the file name into it but the
actual file.

Anyway, seems to me this should be possible.
How about a VBScript instead?
It could be ocnverted to ASP if you want.
Watch for word-wrap.

Save it as "fetches.vbs";
create a file named "fetches.txt" with a list of URLs;
double-click on "fetches.vbs" to run it via WScript.exe;
each URL will be downloaded into the "fetches" subfolder;
the filename is the URL without the domain and "_" were "/";
"fetches.log" will summarize the success or failure of each.

<< "fetches.vbs" >>

Option Explicit
'****
'* Fetch a list of URLs per "cTXT" into subfolder "cFOL".
'* Log the activity into "cLOG".
'****
'*
'* Declare Constants
'*
Const cVBS = "fetches.vbs"
Const cTXT = "fetches.txt"
Const cLOG = "fetches.log"
Const cFOL = "fetches\"
'*
'* Declare Variables
'*
Dim strDIR
strDIR = WScript.ScriptFullName
strDIR = Left(strDIR,InStrRev(strDIR,"\"))
Dim arrOTF
Dim intOTF
Dim strOTF
Dim strOUT
Dim intURL
intURL = 0
Dim strPAG
Dim strURL
'*
'* Declare Objects
'*
Dim objCTF
Dim objFSO
Dim objOTF
'*
'* Started
'*
MsgBox "Started.",vbInformation,cVBS
'*
'* Assign Objects
'*
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCTF = objFSO.CreateTextFile(strDIR & cLOG,True)
objCTF.WriteLine("* Started.")
If Not objFSO.FileExists(strDIR & cTXT) Then
objCTF.WriteLine("* Failed!")
WScript.Quit
End If
Set objOTF = objFSO.OpenTextFile(strDIR & cTXT,1)
'*
'* Create Folder
'*
If Not objFSO.FolderExists(strDIR & cFOL) Then
objFSO.CreateFolder(strDIR & cFOL)
End If
'*
'* Fetch URLs
'*
strOTF = objOTF.ReadAll
arrOTF = Split(strOTF,vbCrLf)
For intOTF = 0 To UBound(arrOTF)
strURL = arrOTF(intOTF)
If Left(strURL,4) = "http" Then
intURL = intURL + 1
strPAG = strURL
strPAG = Mid(strPAG,InStr(strPAG,"//")+2)
strPAG = Mid(strPAG,InStr(strPAG,"/")+1)
strPAG = Replace(strPAG,"/","_")
strOUT = strDIR & cFOL & strPAG
If Fetch(strURL,strOUT) Then
objCTF.WriteLine("+ " & strURL)
Else
objCTF.WriteLine("- " & strURL)
End If
End If
Next
'*
'* Destroy Objects
'*
Set objOTF = Nothing
objCTF.WriteLine("# URLs = " & FormatNumber(intURL,0))
objCTF.WriteLine("* Finished.")
Set objCTF = Nothing
Set objFSO = Nothing
'*
'* Finished
'*
MsgBox "Finished.",vbInformation,cVBS

Function Fetch(xURL,xOUT)
On Error Resume Next
Err.Clear
Dim b
With CreateObject("Microsoft.XMLHTTP")
.Open "GET",xURL,False
.Send
b = .ResponseBody
If Err.Number <0 Or .Status <200 Then
Fetch = False
Exit Function
End If
End With
With CreateObject("ADODB.Stream")
.Type = 1
.Open
.Write b
.SaveToFile xOUT,2
End With
Fetch = Err.Number = 0
End Function

<< Example "fetches.txt" >>

http://www.google.com/intl/en_ALL/images/logo.gif
http://images.google.com/intl/en_ALL.../images_hp.gif
http://www.google.com/intl/en_us/images/maps_logo.gif
http://news.google.com/images/news.gif
http://www.google.com/intl/en_us/images/hp0.gif
https://mail.google.com/mail/help/images/logo.gif

<< Example "fetches.log" >>

* Started.
+ http://www.google.com/intl/en_ALL/images/logo.gif
+ http://images.google.com/intl/en_ALL.../images_hp.gif
+ http://www.google.com/intl/en_us/images/maps_logo.gif
+ http://news.google.com/images/news.gif
+ http://www.google.com/intl/en_us/images/hp0.gif
+ https://mail.google.com/mail/help/images/logo.gif
# URLs = 6
* Finished.

<< Example contents of sunfolder "fetches\" >>

intl_en_ALL_images_logo.gif
intl_en_ALL_images_images_hp.gif
intl_en_us_images_maps_logo.gif
images_news.gif
intl_en_us_images_hp0.gif
mail_help_images_logo.gif
Dec 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Norman Peelman | last post by:
I have a script that outputs images directly using the 'image' functions. I have googled quite a bit but cannot seem to find the correct method of sending headers to keep the images from being...
8
by: Jonathan Daugherty | last post by:
Does anyone here know if the wxImage class in wxPython supports dislaying images from URLs? -- Jonathan Daugherty http://www.cprogrammer.org "It's a book about a Spanish guy called Manual,...
5
by: Andreas Volz | last post by:
Hi, I used SGMLParser to parse all href's in a html file. Now I need to cut some strings. For example: http://www.example.com/dir/example.html Now I like to cut the string, so that only...
2
by: DiggidyMack69 | last post by:
Hello folks I have a rolling image script that works fine except that the images do not seem to be preloading properly. The images are still being pulled on every interval from the server...
9
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this...
2
by: mikeoley | last post by:
Ok I have a Javascript slideshow working. Every image is linked to a another page in the site. Problem is...The link wont refresh to the next link once the second images rollovers in the slideshow....
6
by: Edward | last post by:
I have been doing some research about embedding images in HTML using the data URL src method of the format: <img src="/-/data:image/gif;base64,<DATA>"> My question is, how does one generate...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.