I am trying to download Xcode from the Apple Developer site using just wget or curl. I think I am successfully storing the cookie I need to download the .dmg file, but I am
Not optimal but works for me:
If you know direct URL for download (e.g. you started download) then you can log-in on developer portal and run the following JS in console:
copy('wget -c http://adcdownload.apple.com//Developer_Tools/xcode_6_beta_5_za4gu6/xcode_6_beta_5.dmg --header="Cookie:' + document.cookie + '"')
This will copy wget command in clipboard with all necessary cookies for wget to work. You can restart this command anytime to continue.
So I've seemed to figure out the answer to my own question. Here's how you can download Xcode using curl.
First, run this:
curl \
-L -s -k \
--cookie-jar cookies \
-A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \
https://developer.apple.com/devcenter/ios/login.action \
-o login.html
Open the login.html
file that's created and look for these 2 things:
action
attribute of the login form. It should be on/around line 54.input
field named wosid
. This should be on/around line 129.Copy the value of the action
attribute as well as the value of the value
attribute of the input field. You'll need these for the next step.
Here's the next curl command:
curl \
-s -k --cookie-jar cookies --cookie cookies \
-A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \
-e ";auto" "https://daw.apple.com{ACTION}?theAccountName={USERNAME}&theAccountPW={PASSWORD}&theAuxValue=&wosid={WOSID}&1.Continue.x=0&1.Continue.y=0" \
> /dev/null
{ACTION}
with the action value you saved{USERNAME}
and {PASSWORD}
with your Apple Dev Center credentials{WOSID}
with the wosid value you saved You should now have the cookie that will allow you to download the .dmg file. If you haven't noticed by now, the cookie is stored in a file called cookies
.
Now just run this last curl command and the Xcode image should begin downloading:
curl \
-L --cookie-jar cookies --cookie cookies \
-A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \
-O https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg
I've tried this on 2 different machines and works on both.