You create a temporary auto-submitting HTML page, point the browser to that page, and after a couple of seconds, you remove the temporary HTML file as it is no longer needed. In script form:
#!/bin/bash
# Create an autodeleted temporary directory.
Work="$(mktemp -d)" || exit 1
trap "cd / ; rm -rf '$Work'" EXIT
# Create a HTML page with the POST data fields,
# and have it auto-submit when the page loads.
cat > "$Work/load.html" <<END
<!DOCTYPE html>
<html>
<head>
<title>…</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function dosubmit() { document.forms[0].submit(); }
</script>
</head>
<body onload="dosubmit();">
<form action="https://www.startpage.com/do/asearch" method="POST" accept-charset="utf-8">
<input type="hidden" name="cat" value="web">
<input type="hidden" name="cmd" value="process_search">
<input type="hidden" name="language" value="english">
<input type="hidden" name="engine0" value="v1all">
<input type="hidden" name="query" value=""Nominal Animal"">
</form>
</body>
</html>
END
# Load the generated file in the browser.
firefox "file://$Work/load.html"
# Firefox returns immediately, so we want to give it a couple
# of seconds to actually read the page we generated,
# before we exit (and our page vanishes).
sleep 2
Let's change the above, so that we do a StartPage search on whatever string(s) are supplied on the command line:
#!/bin/bash
# Create an autodeleted temporary directory.
Work="$(mktemp -d)" || exit 1
trap "cd / ; rm -rf '$Work'" EXIT
# Convert all command-line attributes to a single query,
# escaping the important characters.
rawAmp='&' ; escAmp='&'
rawLt='<' ; escLt='<'
rawGt='>' ; escGt='>'
rawQuote='"' ; escQuote='"'
QUERY="$*"
QUERY="${QUERY//$rawAmp/$escAmp}"
QUERY="${QUERY//$rawQuote/$escQuote}"
QUERY="${QUERY//$rawLt/$escLt}"
QUERY="${QUERY//$rawGt/$escGt}"
# Create a HTML page with the POST data fields,
# and have it auto-submit when the page loads.
cat > "$Work/load.html" <<END
<!DOCTYPE html>
<html>
<head>
<title>…</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function dosubmit() { document.forms[0].submit(); }
</script>
</head>
<body onload="dosubmit();">
<form action="https://www.startpage.com/do/asearch" method="POST" accept-charset="utf-8">
<input type="hidden" name="cat" value="web">
<input type="hidden" name="cmd" value="process_search">
<input type="hidden" name="language" value="english">
<input type="hidden" name="engine0" value="v1all">
<input type="hidden" name="query" value="$QUERY">
</form>
</body>
</html>
END
# Load the generated file in the browser.
firefox "file://$Work/load.html"
# Firefox returns immediately, so we want to give it a couple
# of seconds to actually read the page we generated,
# before we exit (and our page vanishes).
sleep 2
All that changes is the chunk where we use Bash string operations to replace each &
with &
, each "
with "
, each <
with <
, and each >
with >
, so that the query string can be safely written as the value
attribute of the hidden input named query
. (Those four suffice. It is also important to do the ampersand first, because the subsequent replacements contain ampersands. Since we emit this as the value of a hidden input, the query string is not url-encoded; it's just normal HTML content, but without doublequotes (because the value itself is in doublequotes).)
The downside of auto-submitting POST requests is that you may need to update your auto-submitting HTML page every now and then, simply because the site can change the POST variable naming and internal URLs whenever they want.