I would like to save as a Firefox bookmark a page which is not accessible using GET. The only way to retrieve the page is to send some POST data.

For example, I would like to bookmark a Chronopost parcel tracking page, which only allows POST for entering parcel numbers.

Does anyone know a Firefox extension, or some other technique, which would allow me to do this?

link|improve this question

Just a geek note: GET requests aren't supposed to change data, that's why you can bookmark them and can call them as often as you like. POST requests are allowed to change state on the server, which is why they're not easily bookmarked. On POST links you bookmark, think about if calling them multiple times will cause problems, such as buying an extra item from Amazon. – Rich Homolka May 19 at 18:32
feedback

4 Answers

up vote 5 down vote accepted

Use a bookmarklet. For example, you can use the tool at http://userjs.up.seesaa.net/js/bookmarklet.html to create a bookmarklet with the following code:

(function(){
  var post_to_url = function(path, params, method) {
    var openWindow = window.open("");
    method = method || "post"; 
    var form = openWindow.document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);
    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);
        form.appendChild(hiddenField);
    }
    openWindow.document.body.appendChild(form);
    form.submit();
  };
post_to_url(
  'http://www.chronopost.fr/transport-express/livraison-colis/engineName/search/accueil/suivi', 
  {search:'test'});
})()

Then use the generated bookmarklet link as a bookmark in your favorite browser. When you click it, it will open a window, create a form with the parameters {search:'test'}, and submit that form.

To change the URL and parameters, just tweak that last call to post_to_url.

This strategy can be great if you just need to create the bookmark once and use it a lot of times. However, it doesn't make it terribly easy to create new bookmarks if you need to do that on a regular basis.

link|improve this answer
feedback

From what I understand about post, there's no way to record that data yourself and re-send it.

I suggest getting an add-on that fills out forms for you better than firefox does by default.

Chrome actually has a very powerful form recognition and filling out feature built in, but i'm sure there is a firefox addon that does the same thing.

Try this one, it looks promising: Form Saver Firefox Add-on

link|improve this answer
But sadly Chrome doesn't offer to save passwords for generic HTTP AUTH pages. – qroberts Oct 18 '10 at 18:50
feedback

Use the iMacro plugin, available for firefox and chrome.

link|improve this answer
feedback

I modified a little the script supplied by @StriplingWarrior to accept a HAR file as parameter. The HAR file can be saved from Chrome's Developer Tools (Ctrl+Shift+J).

First open the page with the form data already posted, then right click the first document on the Network tab and select "Copy entry as HAR". Then paste the content on the script below:

<html><body><script>
function dopost() {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", har["request"]["url"]);
var params = har["request"]["postData"]["params"];
for(var e in params) {
    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", params[e]["name"]);
    hiddenField.setAttribute("value", params[e]["value"]);
    form.appendChild(hiddenField);
}
document.body.appendChild(form);
form.submit();
}
window.onload=dopost;

var har=
//-----PASTE HERE------

</script>
</body></html>

Save this as a html file and it should open the posted form. This don't work if the site uses viewstate or if it checks the referrer.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.