【问题标题】:creating gmail accounts with python使用 python 创建 gmail 帐户
【发布时间】:2023-02-17 11:30:35
【问题描述】:

我正在尝试使用我在媒体上找到的一篇文章使用 python 创建一个 gmail 帐户。这是文章:https://betterprogramming.pub/creating-temporary-gmails-accounts-with-python-9c200c52ebb7

这是我的代码:

def generate_gmail(ID: int):
  
  # access the API
  url = "https://temp-gmail.p.rapidapi.com/get"
  querystring = {"id":ID,"type":"alias"}
  headers = {
    'x-rapidapi-host': "temp-gmail.p.rapidapi.com",
    'x-rapidapi-key': "YOUR PRIVATE KEY"
    }
  
  # send a request to the API
  response = requests.request("GET", url, headers=headers, params=querystring)
  
  # convert the response to JSON format 
  json_response = response.json()
  # get gmail address
  gmail = json_response['items']['username']
  # get gmail password
  password = json_response['items']['key']

  print('Gmail address: %s' % str(gmail))
  print('Password: %s' % str(password)) 

我已经输入了我的私钥。当我在终端中使用“python3 file_name.py”运行代码时,我没有收到电子邮件和密码的输出。我究竟做错了什么?

【问题讨论】:

  • 您的代码只定义了一个函数,但没有调用它。
  • 你确定你是按照那篇文章一步一步来的吗?您是否在“file_name.py”中的某处调用了 generate_gmail(ID=YOUR_ID)?

标签: python api gmail


【解决方案1】:

添加print(json_response['message'])

如果您收到消息“您没有订阅此 API”。那么你还没有订阅。

【讨论】:

    【解决方案2】:

    只需要调用函数 将此行添加到您的代码中

    生成_gmail(ID:3)

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 2022-12-18
      • 2013-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-29
      • 1970-01-01
      • 2021-07-30
      相关资源
      最近更新 更多