2012-01-19 5 views
9

Gmail에는 모든 연락처를 CSV 파일로 내보낼 수있는 편리한 창이 있습니다. 이 후 브라우저의 역사를 볼 경우, 당신은 다운로드를 시작하는 데 사용되는 URL이 같은 보이는 것을 볼 수 :무인 스크립트를 통해 Gmail 연락처 내보내기

https://mail.google.com/mail/c/data/export?exportType=GROUP&groupToExport=%5EMine&out=GMAIL_CSV&tok=rQt5BTUBABA.N0gr2-zKkG9868fM7tF_FQ.fOgeVayblkGavK2AuFjZ2t

내가 자동으로 CSV를 다운로드합니다 파이썬에서 배치 스크립트를 작성하려

매일 밤 내 서버에 파일을 보내지 만, "tok"를 얻는 방법을 알아낼 수는 없습니다. 나는 Google의 OAuth를 살펴 봤지만 인간과 상호 작용하는 과정 인 것처럼 보이지만 모든 가능한 사람이 잠들 때 3AM에서 발생해야합니다.

Google이 내 전자 메일 계정을 무인 스크립트를 통해 액세스 할 수 없도록 "안전"하도록 만들 수 있습니까?

감사합니다. 브라이언 M. 엘리엇

+0

언제든지 셀렌 등으로 프로그래밍 할 수 있습니다. 브라우저 창을 프로그래밍 방식으로 열고 gmail 등에 로그인합니다. – katrielalex

+0

또한 Backupify가이를 수행 할 수 있으므로 확실히 가능합니다. – katrielalex

답변

2

내가 어떤 준비 솔루션 필자는 그것을 자신을 수행 발견을 couldnt : (PLS 게으른 스크립트 나와 함께 곰, 그냥 작업을 얻을 싶었 :

#!/bin/sh 
# google api requirements: 
# https://developers.google.com/gdata/articles/using_cURL 
# https://developers.google.com/gdata/faq#clientlogin 
# https://developers.google.com/google-apps/contacts/v3/ 
# https://developers.google.com/google-apps/contacts/v3/reference 
# json parser: 
# https://github.com/dominictarr/JSON.sh#jsonsh 
# recommendation(optional): 
# https://developers.google.com/accounts/docs/OAuth2UserAgent 

# echo "logging in to google and saving contact with given caller-number." 
Auth=$(curl --silent https://www.google.com/accounts/ClientLogin --data-urlencode Email=${Email} --data-urlencode Passwd=${Passwd} -d accountType=GOOGLE -d source=Google cURL-Example -d service=cp | grep Auth | cut -d= -f2) 
curl -o ${dir}/${tmpfile} --silent --header "Authorization: GoogleLogin auth=$Auth" "https://www.google.com/m8/feeds/contacts/$Email/full?v=3.0&q=$2&alt=$Format" 

당신이 솔루션에 도착하는 데 도움이 될 D))

3

먼저 계정과 암호 인증 (http://developers.google.com/accounts/docs/AuthForInstalledApps 참조)

auth=`curl --silent -d [email protected] -d Passwd=yourpwd -d service=contacts https://www.google.com/accounts/ClientLogin|grep ^Auth=|cut -d= -f2` 

myserious "tok"변수를 얻습니다. JSON 요청의 일부인 것으로 확인되었습니다.

tok=`curl --silent --header "Authorization: GoogleLogin auth=$auth" "https://www.google.com/s2/gastatus?out=js&rc=0" |sed 's/,/\n/g' |grep AuthToken |cut -d'"' -f6` 

CSV (Google 형식)를 다운로드하십시오. 이것이 바로이 일을 수동 방식과 동일합니다 : google_csv, outlook_csv, vCard를 중 하나가 될 수 있습니다 "에서"

curl -s --stderr - -L -o contacts-google-whatever\@gmail.com-$(date +%Y-%m-%d-%H.%M.%S).csv -H "Authorization:GoogleLogin auth=$auth" --insecure "https://www.google.com/s2/data/exportquery?ac=false&cr=true&ct=true&df=true&ev=true&f=g2&gids=6&gp=true&hl=en-US&id=personal&max=-1&nge=true&out=google_csv&sf=display&sgids=6%2Cd%2Ce%2Cf%2C17&st=0&tok=$tok&type=4" 

변수

을 support.google.com/mail/answer/24911?hl=en. 내 코드는 bash이므로 curl 명령을 파이썬과 동등한 것으로 변경할 수 있습니다. 중요한 정보는 변수와 URL입니다.

+0

왜 작동합니까? 여기서 뭘하고 있는지 설명해주세요. – rayryeng

+0

첫 번째 줄은 계정과 비밀번호로 인증하는 것입니다 (https://developers.google.com/accounts/docs/AuthForInstalledApps 참조). 두 번째 줄은 "tok"변수를 얻는 것입니다. JSON 요청의 일부라는 것을 알았습니다. 마지막 행은 CSV (Google 형식)를 다운로드하는 것입니다.이 작업을 수행하는 수동 방법과 정확히 같습니다. https://support.google.com/mail/answer/24911?hl=en out 변수는 google_csv, outlook_csv, vcard 중 하나 일 수 있습니다. – SoftIce

0

아무 것도 찾을 수 없으므로이 작업을 수행하는 litte 도구를 만들었습니다. 여기 https://github.com/gedl/gc-csv

그것은 콘솔에, 쉼표로 구분 된 파일로 구글 연락처를 내보내거나 VOIP 전화 (인컴 ICW1000G)

나는 그것이 도움이되기를 바랍니다에 업로드 할 수 있습니다 찾을 수 있습니다.

관련 문제