Quick script to download an XML file

  • Thread starter Thread starter RDM
  • Start date Start date

RDM

RDM

Soldato
Joined
1 Feb 2007
Posts
20,612
Anyone have any idea how to automate downloading an XML file from the web? It is an interim measure till a website redesign is done.
 
For a *nix system you could set up a cron job calling a script which does this:
Code:
wget http://somexml.xml
Could use curl, too.

Windows (I think) is a bit more involved, but should be quite easy to code, it just depends on the language of choice :)

Edit:
Found small piece of code for python (assuming you've got it installed):
Code:
import urllib2

req = urllib2.Request('http://somexml.xml')
file=open('path_to_save.xml','w')
file.writelines(urllib2.urlopen(req))
file.close()
Save it into a file (after making a few chages) and set up a scheduled job on windows.
 
Last edited:
How to force download in windows/ASP -

Code:
	Response.ContentType = "application/x-unknown" ' arbitrary 
	szPath = "D:\path_to_site\" & szFilename     
	Response.AddHeader "Content-Disposition","attachment; filename=" & szFilename 
	 
	set adoStream = server.createobject("ADODB.Stream") 
	adoStream.Open() 
	adoStream.Type = 1 
	adoStream.LoadFromFile(szPath) 
	response.BinaryWrite adoStream.Read() 
	adoStream.Close 
	set adoStream = nothing
 
Back
Top Bottom