Created
March 27, 2014 05:13
-
-
Save tonejito/9800785 to your computer and use it in GitHub Desktop.
Fetch resource following all Location headers, setting the apropriate referer and saving all the cookies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -vx | |
# | |
# ./follow-curl.sh | |
# Fetch resource following all Location headers and setting the apropriate referer and saving all the cookies | |
# | |
# Andres Hernandez - tonejito | |
# Released under the BSD license | |
# | |
CAT=cat | |
CURL=curl | |
MKTEMP=mktemp | |
function help() | |
{ | |
echo " | |
Usage: ${0} <URL> [<cookie>] | |
<URL>: URL to be downloaded | |
<cookie>: cURL's cookie jar filename | |
" ; | |
} | |
if [ -n "${1}" ] | |
then | |
URL=${1} | |
else | |
help; | |
exit 1; | |
fi | |
if [ -n "${2}" ] | |
then | |
COOKIE=${2} | |
else | |
COOKIE=`$MKTEMP --tmpdir=.` | |
fi | |
$CURL -vk# --location --referer ';auto' -A '' --cookie $COOKIE --cookie-jar $COOKIE $URL | |
$CAT $COOKIE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment