inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

업무 자동화 첫걸음: Python으로 이메일 대량 전송하기와 크롤링 프로젝트 완성하기

Gmail API를 사용한 메일 전송

샘플 코드가 다른거 같아요.

해결된 질문

374

우동현

작성한 질문수 2

1

안녕하세요, 수강생 여러분

  1. 학습 관련 내용을 질문해주세요!

     

영상에나온 Gmail Api python 샘플 코드와 현재 구글에서 제공하는 샘플 코드가 다른거같아요.

영상에서 나온 코드를 직접 타이핑 하면될까요?

참고로 구글에서 제공하는 샘플코드는 아래와 같아요.

import os.path

from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

# If modifying these scopes, delete the file token.json.
SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"]


def main():
  """Shows basic usage of the Gmail API.
  Lists the user's Gmail labels.
  """
  creds = None
  # The file token.json stores the user's access and refresh tokens, and is
  # created automatically when the authorization flow completes for the first
  # time.
  if os.path.exists("token.json"):
    creds = Credentials.from_authorized_user_file("token.json", SCOPES)
  # If there are no (valid) credentials available, let the user log in.
  if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
      creds.refresh(Request())
    else:
      flow = InstalledAppFlow.from_client_secrets_file(
          "credentials.json", SCOPES
      )
      creds = flow.run_local_server(port=0)
    # Save the credentials for the next run
    with open("token.json", "w") as token:
      token.write(creds.to_json())

 

 

  1. 개인적으로 스크래핑/크롤링하는 사이트에 대한 질문에 대해서는 답변을 드리지 않아요!

python slack beautifulsoup github-actions gmail-api

답변 1

1

허곰

안녕하세요 우동현님!

먼저 강의에 나온코드는 구글 샘플 코드를 참조한 코드이며, 약간 변형이 있습니다.

강의에 나온것을 사용하시면 되며, 복사를 원하시는 경우 아래 깃허브 주소에서 가져가시면 됩니다!

https://github.com/heohyunjun/Inflearn-road-to-business-automation

감사합니다, 추가 질문있으신 경우 언제든 남겨주세요!

1

우동현

네 감사합니다.

실행되었습니다.^^

 

친절한 설명 감사합니다.

라이브 강의 영상 녹화본이 있을까요?

0

6

0

.env

0

16

4

인증이 늦었습니다ㅜㅜ 확인부탁드립니다

0

27

1

화면이 안보입니다

0

15

0

mmcv 문의 드립니다.

0

22

2

검색 대상 종목 선정

1

22

2

수업자료

0

18

1

수강 기간 연장 가능 여부 문의드립니다

0

28

1

llm_decision_logs 미적재 문의

1

21

2

강의 교재가 있나요?

0

29

2

3-1 sub 폴더를 찾을 수 없습니다

0

23

1

연동 문제

1

38

2

키보드 단축키 알려주세요!

0

22

1

5-21 질문이요!

1

41

3

강의자료 누락

0

36

1

강의 업데이트

0

37

2

블로그 내용 정리

0

25

1

3.1.강화학습 기본 알고리즘-마르코프 결정과정

0

45

2

매수 실행 시점 관련

1

36

1

영상 다운로드는 안되나요?

0

47

1

수강자료 다운로드 관련 문의

0

65

2

Opus/Sonnet 버전 관련 문의

1

52

2

vs code와 github연결 방법을 모르겠어요

0

308

1

토큰 문제가 발생했어요

1

526

1