0
I'm attempting to automate a login for the a course webpage I have to check this semester. I know that the POST request I am making is being done correctly because I get to the intermediate redirect page that you only get on a successful login.
I'm basically hitting one of those This page should automatically redirect. If nothing is happening please use the continue link below.
pages. Unfortunately because curl isn't following this final redirect, it doesn't seem to be setting the last cookies to keep my session.
I've been reading the man
for curl, but I can't seem to find the correct way to get this done (--max-time
and --max-redirs
are what I've tried and aren't working).
Can anyone tell me what I need to do to resolve this?
Here's what' I'm working with
LOGINURL="http://www.[redacted].edu/login/index.php" # This is not https because they don't support it.
COURSEURL="http://www.[redacted].edu/course/[redacted]"
USERAGENT="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
COOKIEJAR="${HOME}/edu.cookies"
POSTDATA="[redacted]"
curl -o "index.html" --referer "${LOGINURL}" --user-agent "${USERAGENT}" --cookie-jar "${COOKIEJAR}" --data "${POSTDATA}" "${LOGINURL}"
curl -o "course.html" --referer "${LOGINURL}" --user-agent "${USERAGENT}" --cookie "${COOKIEJAR}" "${COURSEURL}"
PS, the link that is provided on the intermediate redirect page is the same link as the COURSEURL url, so manually curling it does not work.
Do you know what kind of redirect they're using? Javascript? Server side? META refresh? – ernie – 2014-08-29T22:17:25.967
1@ernie I just barely saw your comment, it's a server-side redirect. The page's source doesn't have any Javascript or have a Meta-Refresh. It turns out all curl needed was
-L
. – Paul Nelson Baker – 2014-08-29T22:23:45.830