3

wget has nice option that lets you allow downloading multiple files from same location

(I mean combination of --base and --input-file)

Advantage of this, is that if possible wget tries to reuse opened socket/connection.

I was wondering if it's possible to do multiple POST request using wget. (I probably end up writing it in python, as I wasn't able to find such use in wget's docs)

i.e. inside input file I would have post data (json in my case):

{"results":1} 
{"results":2}

and request like:

wget --header "Content-Type: application/json" -i input.data http://example.com/api/data

1 Answer 1

2

I think your are looking for --post-file parameter. -i is used for the GET method (providing an URL list), not POST :

wget --header "Content-Type: application/json" --post-file input.data http://example.com/api/data

You can refer to man page

An alternative could be to use curl :

curl -H "Content-Type: application/json" -X POST -d @input.data  http://example.com/api/data

You can refer to man page

3
  • not really, both --post-file, and -d for curl, specify file that will be send in a single request, what I hoped to have is a single file with post data for multiple requests :/
    – GiM
    May 5, 2015 at 20:22
  • Not sure to get why you need multiple request when only one should be enough...You certainly have your reason but i would be glad to know about them. By the way, a script using a for loop request for each line in file will produce a request for each iteration...
    – krisFR
    May 5, 2015 at 20:32
  • yes, I know I could simply do for. As I've written in content (regarding --input-file): "Advantage of this, is that if possible wget tries to reuse opened socket/connection." I had some data that I wanted to download, and result differ only when different post data is being sent.
    – GiM
    May 5, 2015 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .