In response to my previous post about cURL as a swiss army knife for web pages, a number of people have asked my about real example to use pattern based downloading of cURL, so here is a small post about that.
Disclaimer: Please note that this is for educational purpose only and illegal use is not recommended or endorsed by me.
Now, the real part:
Let’s say you wanted to download multiple files, text, data, mp3 or videos etc. Take an example of MP3 sngs for new hindi movie Delhi Belly. These songs are available on multiple sites including one URL here.
Again note, that downloading songs from this or any other site may be against local & any other applicable laws based upon where you reside.
Here are the steps
1) Open the URL.
2) You would find that the download URL is something like http://link1.songspk.pk/song1.php?songid=8520 for the first song. and the download URL for the last song is something like http://link1.songspk.pk/song1.php?songid=8529
3) Now, if you wanted to use cURL pattern base download use, you can do something like:
curl -L http://link1.songspk.pk/song1.php?songid=85{20,21,22,23,24,25,26,27,28,29} -O
-L option is to follow redirect, in case, the server is throwing some intermediate redirect.
-O option is to save them as local files rather than sending it to STDOUT.
4) This would download all files one by one and it would have having typing each file individually, handling redirects, and then saving them to local files.
5) After that you may need to rename all of them as MP3s, s you can run ren * *.mp3 (on windows) or mv * *.mp3 (on UNIX).
Happy cURL ing …
for any questions or doubts, please post in comments.
EDIT: songs.pk has moved to songspk.pk after the old domain was banned.
Hi,Pradeep
The post is really interesting .Could u please post the script ,as i m totally new to CURL
Hi Syed
There is no generic script. Based upon what all files you want to download, you would issue a command similar to mentioned in step #3.
Please go through the post & let me know, if you have any specific questions.
PS
So is it correctly understand that if I wanted to download ALL songs (generic) in a specific library that would not be possible? If it was, how would the curl look please?
Thx for the blog btw 😉
Hi there! I know this is kind of off topic
but I was wondering if you knew where I could find a captcha plugin for my comment form?
I’m using the same
blog platform as yours and I’m having difficulty finding one?
Thanks a lot!
Hi,
You can find captcha plugins for wordpress at
https://wordpress.org/plugins/si-captcha-for-wordpress/
Thanks
PS