Download Google Docs without a browser

    The skriptik looks something like this: And now, as is customary, exposure.

    #!/bin/bash
    token=$(curl -s www.google.com/accounts/ClientLogin -d Email=user.name@gmail.com -d Passwd=qwerty -d accountType=GOOGLE -d service=writely -d Gdata-version=3.0 |cut -d "=" -f 2)
    set $token
    curl --silent --header "Gdata-Version: 3.0" --header "Authorization: GoogleLogin auth=$3" "http://docs.google.com/feeds/user.name@gmail.com/private/full" | tidy -xml -indent -utf8 -quiet > /tmp/gdocs.xml
    file=(doc1 doc2 doc3 doc4)
    resourceId=(document:0ASpnxqo7zPlfZGQ3Z2Zwc183NWZteDNiM2Y ...) # и ещё 3 resourceId
    i=0
    while (( i < 4 )) # match num_files
    do
    wget --header "Gdata-Version: 3.0" --header "Authorization: GoogleLogin auth=$3" "https://docs.google.com/feeds/download/documents/Export?docID=${resourceId[$i]}&exportFormat=txt" -O /tmp/${file[$i]}.txt

    sleep 2
    i=$i+1
    done


    • The first line is the authentication token. Next, we present it for downloading the RSS feed, which we save to a file. Next, we take resourceId from it and download the docks. Here you should make a reservation that resourceId is taken "manually" from a saved RSS file. It is possible, of course, to automate this, but if there are not many documents, then it is not necessary to inflate the script.
    • Link for downloading docks:
      GET /feeds/download/documents/Export?docID=resource_id&exportFormat=format
    • service = writely. The list of Google service code names is taken from here .
    • resourceId is a key element. This is the dock id. We take it from the RSS feed downloaded to the file /tmp/gdocs.xml . Relevant tags look like this and are in the same entry as the name of the docks.

      document:0ASpnxqo7zPlfZGQ3Z2Zwc183Zzc3NnZkY2g

    • exportFormat = txt. You can select other formats for download. The list is here .
    It is written in haste, so any comments and criticism are welcome.

    Also popular now: