Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl Command to Repeat URL Request

Tags:

linux

url

curl

Whats the syntax for a linux command that hits a URL repeatedly, x number of times. I don't need to do anything with the data, I just need to replicate hitting refresh 20 times in a browser.

like image 694
mathematician Avatar asked Sep 13 '12 15:09

mathematician


People also ask

How do I send a parallel request in curl?

The solution to this is to use the xargs command as shown alongside the curl command. The -P flag denotes the number of requests in parallel. The section <(printf '%s\n' {1.. 10}) prints out the numbers 1 – 10 and causes the curl command to run 10 times with 5 requests running in parallel.

How do you curl a URL?

The syntax for the curl command is as follows: curl [options] [URL...] In its simplest form, when invoked without any option, curl displays the specified resource to the standard output. The command will print the source code of the example.com homepage in your terminal window.

What happens when you curl a URL from the command line?

cURL, which stands for client URL, is a command line tool that developers use to transfer data to and from a server. At the most fundamental, cURL lets you talk to a server by specifying the location (in the form of a URL) and the data you want to send.


2 Answers

You could use URL sequence substitution with a dummy query string (if you want to use CURL and save a few keystrokes):

curl http://www.myurl.com/?[1-20] 

If you have other query strings in your URL, assign the sequence to a throwaway variable:

curl http://www.myurl.com/?myVar=111&fakeVar=[1-20] 

Check out the URL section on the man page: https://curl.haxx.se/docs/manpage.html

like image 173
alexm Avatar answered Nov 16 '22 04:11

alexm


for i in `seq 1 20`; do curl http://url; done 

Or if you want to get timing information back, use ab:

ab -n 20 http://url/ 
like image 43
matt b Avatar answered Nov 16 '22 02:11

matt b