There’s a variety of ways to perform http request without using your web browser, i.e. using your command prompt. We could use wget for most major Linux distributions, but what about Windows? Recently I’ve found out that cURL might get the job done.

cURL is a command line tool for transferring files with URL syntax. It is free and open source software. One of the use for cURL is to automate unattended file transfers. For example, automating file downloads or getting html output from sites, via a command prompt, a batch file or scheduled job. It is also a good tool for simulating a user’s actions at a web browser, thus a very good tool to perform web application tests.

How to use cURL:

1. Download cURL. Select appropriate version based on your OS.
2. Extract the zip file.
3. Place the “curl.exe” under your C:\WINDOWS directory.
4. Execute it directly from your command prompt:

C:\>curl http://www.wordpress.org

You will see a bunch of http response coming out of your command prompt.

Output http response and save the page locally :
C:\>curl http://www.mydomain.com/mypage.php > mypage.html

Downloading using cURL:
C:\>curl http://www.mydomain.com/downloads/myfile.zip

HTTP Post using cURL:
C:\>curl -d "string_to_post" http://www.mydomain.com/mypage.aspx

There’s a lot more features for cURL, and the manual usage available here.

No related posts.

Comments

  1. From dirn on September 6th, 2008 at 3:35 am

    great tools, wget == curl…

  2. From mancai on September 6th, 2008 at 4:52 pm

    macam mano tu tak reti aa teman bermain programing ni…
    sound menarik…nak try aa gak…

  3. From nazham on September 6th, 2008 at 10:08 pm

    @dirn: Yeah, I’ve been looking for this for a while. Can do the same as wget in Linux.
    @mancai: Thank for dropping by. :) . Tak payah programming pun. Download, follow step 1-3, pas tu execute. Buleh download file mcm ni:
    C:\>curl http://www.mydomain.com/downloads/myfile.zip

  4. From azlan on September 6th, 2008 at 10:37 pm

    ooo.baru ku tahu..wget == cURL….dah lama x pakai window…hehe

  5. From Ras on September 8th, 2008 at 7:23 am

    aku pakai fiddler. but it’s not a command line tool.

  6. From Rizal on September 8th, 2008 at 9:24 am

    Thanks, this is very useful knowledge. I have used cURL before but in PHP. I never realized it was available as a Windows command-line tool.

  7. From Ady on September 8th, 2008 at 10:55 am

    @Rizal: PHP’s curl binding uses libcurl which originates from the same project. As a matter of fact this is one big plus feature against wget — API.

    I use curl even in Linux, especially when troubleshooting pages. As for wget, I use it to download simple files. For big files, I use lftp which has the ability to leech using multiple connections. MUAHAHAHA (evil laugh).

  8. From dirn on September 9th, 2008 at 12:35 am

    lftp? hmm…interesting :)

twitter rss