473,748 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3021
Simon Wigzell wrote on 11 dec 2007 in
microsoft.publi c.inetserver.as p.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**********@s haw.cawrote in message
news:X2A7j.947$ ox1.719@pd7urf3 no...
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.vb s";
create a file named "fetches.tx t" with a list of URLs;
double-click on "fetches.vb s" 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.lo g" will summarize the success or failure of each.

<< "fetches.vb s" >>

Option Explicit
'****
'* Fetch a list of URLs per "cTXT" into subfolder "cFOL".
'* Log the activity into "cLOG".
'****
'*
'* Declare Constants
'*
Const cVBS = "fetches.vb s"
Const cTXT = "fetches.tx t"
Const cLOG = "fetches.lo g"
Const cFOL = "fetches\"
'*
'* Declare Variables
'*
Dim strDIR
strDIR = WScript.ScriptF ullName
strDIR = Left(strDIR,InS trRev(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.",vbIn formation,cVBS
'*
'* Assign Objects
'*
Set objFSO = CreateObject("S cripting.FileSy stemObject")
Set objCTF = objFSO.CreateTe xtFile(strDIR & cLOG,True)
objCTF.WriteLin e("* Started.")
If Not objFSO.FileExis ts(strDIR & cTXT) Then
objCTF.WriteLin e("* Failed!")
WScript.Quit
End If
Set objOTF = objFSO.OpenText File(strDIR & cTXT,1)
'*
'* Create Folder
'*
If Not objFSO.FolderEx ists(strDIR & cFOL) Then
objFSO.CreateFo lder(strDIR & cFOL)
End If
'*
'* Fetch URLs
'*
strOTF = objOTF.ReadAll
arrOTF = Split(strOTF,vb CrLf)
For intOTF = 0 To UBound(arrOTF)
strURL = arrOTF(intOTF)
If Left(strURL,4) = "http" Then
intURL = intURL + 1
strPAG = strURL
strPAG = Mid(strPAG,InSt r(strPAG,"//")+2)
strPAG = Mid(strPAG,InSt r(strPAG,"/")+1)
strPAG = Replace(strPAG, "/","_")
strOUT = strDIR & cFOL & strPAG
If Fetch(strURL,st rOUT) Then
objCTF.WriteLin e("+ " & strURL)
Else
objCTF.WriteLin e("- " & strURL)
End If
End If
Next
'*
'* Destroy Objects
'*
Set objOTF = Nothing
objCTF.WriteLin e("# URLs = " & FormatNumber(in tURL,0))
objCTF.WriteLin e("* Finished.")
Set objCTF = Nothing
Set objFSO = Nothing
'*
'* Finished
'*
MsgBox "Finished.",vbI nformation,cVBS

Function Fetch(xURL,xOUT )
On Error Resume Next
Err.Clear
Dim b
With CreateObject("M icrosoft.XMLHTT P")
.Open "GET",xURL,Fals e
.Send
b = .ResponseBody
If Err.Number <0 Or .Status <200 Then
Fetch = False
Exit Function
End If
End With
With CreateObject("A DODB.Stream")
.Type = 1
.Open
.Write b
.SaveToFile xOUT,2
End With
Fetch = Err.Number = 0
End Function

<< Example "fetches.tx t" >>

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.lo g" >>

* 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_ima ges_logo.gif
intl_en_ALL_ima ges_images_hp.g if
intl_en_us_imag es_maps_logo.gi f
images_news.gif
intl_en_us_imag es_hp0.gif
mail_help_image s_logo.gif
Dec 11 '07 #3

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

Similar topics

7
1796
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 cached... these are dynamic images. Norm
8
7620
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, you should read it." -- Dilbert
5
2102
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 domain and directory is left over. Expected result:
2
1656
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 according to the logs...is it because I am using the document.write method? Is that forcing a refresh? <SCRIPT language="JavaScript" type="text/javascript"> // BEGIN rolling images code
9
2644
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 with a Bitmap the results are Black. Can you somehow Clip the Grafic and Paste it into the Bitmap ? Mark Johnson, Berlin Germany mj10777@mj10777.de
2
1979
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. It only stays at the first images link. Is this a cache issue? Or is there anyway to create a random number to trick this or make it work properly. I'm very raw with Javascript so I'm having trouble figuring this out. Thank you in advance
6
22806
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 this <DATA> string? I have found some on the web that I can load into my browser but if I save this image and then view in Notepad it looks much different than the string that I used in <DATA> and is full of non-alphanumeric symbols. Also, I have...
1
6825
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 file during specific events in the script execution? image format doesnt matter. thanks! christine
6
7238
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 display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.