SoZettaSho
SoZettaSho

Reputation: 1021

Retrieve POST response data with cURL

In jQuery/AJAX you can make POST requests and get their response with something like

$.post(url, data, function(res){ 
  //do something
});

Where res contains the server's response. I am trying to replicate this with cURL in bash.

curl -d "data=data" --cookie cookies.txt --header "Content-Type:text/html" https://example.com/path > result.html

Returns gibberish (some sort of js object maybe?), but I am expecting html. Is there a way to retrieve the data that would be in res using cURL?

Thanks in advance.

Upvotes: 0

Views: 981

Answers (2)

Eric
Eric

Reputation: 1511

Sometimes servers send back compressed content. It looks like random garbage. Use curl --compressed to get the decompressed result.

Upvotes: 1

tanaydin
tanaydin

Reputation: 5316

It seems that you are trying to get a data from a POST request. Server returns you a javascript object. And you are getting it right way, javascript converts returned data to HTML, not cURL. So basically you can't do that.

Upvotes: 0

Related Questions