使用 Python 创建 Gmail 帐户
我正在尝试使用我在 Medium 上找到的一篇文章使用 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
运行代码时,我没有收到电子邮件和密码的输出。我做错了什么?
I am trying to create a gmail account with Python using an article I found on medium. Here's the article: https://betterprogramming.pub/creating-temporary-gmails-accounts-with-python-9c200c52ebb7
Here is my code:
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))
I have input my private key. When I run the code with python3 file_name.py
in terminal I do not receive an output of an email and password. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请添加
print(json_response['message'])
。如果您收到消息“您尚未订阅此 API”, 那么您还没有订阅。
Add
print(json_response['message'])
If you get message "You are not subscribed to this API." then you have not subscribed yet.
只需要调用该函数即可
将此行添加到您的代码中
generate_gmail(ID:3)
Just you need to call the function
Add this line to your code
generate_gmail(ID:3)