Monday, December 6, 2010

script to download gziped xml

Share at Facebook

There is a problem while downloading the gzip xml file from server. I have noticed that sometimes the PHP/Curl and LWP of Perl is not able to gunzip the xml.gz file properly.

There are several ways to handle this problem. First of all you have to download the gzip file into local directory. You can use curl, lwp, or wget. Just download this and save into a file, for example "temp.xml.gz". A wget command you can use from your script.

system('wget "" -nv');

After downloading the script, use gunzip over the file. If you are using linux, that case you already having gunzip installed. If you are using windows, that case you have to get the gunzip.exe. You can download this and place to the script directory. A gunzip command will be,

system("gunzip -f temp.xml.gz");

This way you can handle gz files from any website.


rahul said...

its so nice useful post.

andrew Hudson said...

This a very nice post