Curl Command to Repeat Url Request

Run cURL command every 5 seconds

You can run in while loop.

while sleep 5; do cmd; done

Edit:

If you don't want to use while..loop. you can use watch command.

watch -n 5 cmd

How can I run multiple curl requests processed sequentially?

It would most likely process them sequentially (why not just test it). But you can also do this:

  1. make a file called curlrequests.sh

  2. put it in a file like thus:

    curl http://example.com/?update_=1
    curl http://example.com/?update_=3
    curl http://example.com/?update_=234
    curl http://example.com/?update_=65
  3. save the file and make it executable with chmod:

    chmod +x curlrequests.sh
  4. run your file:

    ./curlrequests.sh

or

   /path/to/file/curlrequests.sh

As a side note, you can chain requests with &&, like this:

   curl http://example.com/?update_=1 && curl http://example.com/?update_=2 && curl http://example.com?update_=3`

And execute in parallel using &:

   curl http://example.com/?update_=1 & curl http://example.com/?update_=2 & curl http://example.com/?update_=3

How to write output of looped curl command to file

You can do this:

while :; do
curl --location --request POST 'https://api.website.com/Auth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: blablabla' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=username' \
--data-urlencode 'password=password'
sleep 2 || break
done >> file.txt

How to repeat Chrome requests as curl commands?

The way I did it was:

  1. Access websites when the developers tools open.
  2. Issue requests, make sure they are logged in the console.
  3. Right click on the requests, select 'Save as HAR with content', and save to a file.
  4. Then run the following php script to parse the HAR file and output the correct curls:

script:

<?php    
$contents=file_get_contents('/home/elyashivl/har.har');
$json = json_decode($contents);
$entries = $json->log->entries;
foreach ($entries as $entry) {
$req = $entry->request;
$curl = 'curl -X '.$req->method;
foreach($req->headers as $header) {
$curl .= " -H '$header->name: $header->value'";
}
if (property_exists($req, 'postData')) {
# Json encode to convert newline to literal '\n'
$data = json_encode((string)$req->postData->text);
$curl .= " -d '$data'";
}
$curl .= " '$req->url'";
echo $curl."\n";
}

CURL: how to run a single curl command 100 times?

You could achieve it by using the below script:

#!/bin/bash

for i in $(eval echo {1..$1})
do
curl -i -H 'Content-Type: text/plain' -X POST -d @hundredencoded http:///aaa/bbb/message &
done


Related Topics



Leave a reply



Submit