网站:UserCheck
账号:[email protected]
密码:google@@@
3 Likes
不是很懂你的需求,文档写得不是很清楚了吗…
1 Like
佬友,主要我是小白,不懂代码,刚学两天Python,只会运行代码
1 Like
木有研究,去瞧瞧
2 Likes
用AI写了个Python 代码,佬友们帮我看看对不对。
我是不是把 # 发送GET请求里的url字样,换成GET连接就行。
那仪表盘里的API应该放在哪里
import requests
def validate_emails(email_list):
for email in email_list:
# 构建请求URL
url = f'https://api.usercheck.com/email/{email}'
# 发送GET请求
response = requests.get(url)
# 处理响应
if response.status_code == 200:
print(f'{email} 是有效的邮箱。')
elif response.status_code == 400:
print(f'{email} 是无效的邮箱。')
elif response.status_code == 429:
print('请求频率过高,请稍后再试。')
else:
print('发生未知错误,请检查响应。')
# 示例邮箱列表
email_list = ['[email protected]', '[email protected]', '[email protected]']
# 调用函数进行邮箱验证
validate_emails(email_list)
key的使用方式,在代码里呈现就是
import requests
headers = {
"Authorization": f"Bearer {API_KEY}"
}
res = requests.get(url, headers=headers).json()
res就是文档里返回的json了
你可以用AI糊一个不懂得再去学
我糊了个长这样,但没试
import csv
import requests
import time
# API key and base URL
API_KEY = "rPIwVIRyrzO4lY4G5REIxri2SLw3JLH5"
BASE_URL = "https://api.usercheck.com/email/"
# Headers for the request
headers = {
"Authorization": f"Bearer {API_KEY}"
}
# Function to check email validity
def check_email(email):
url = f"{BASE_URL}{email}"
response = requests.get(url, headers=headers)
if response.status_code == 200:
result = response.json()
return {
"email": result.get("email", email),
"domain": result.get("domain", ""),
"mx": result.get("mx", False),
"disposable": result.get("disposable", False),
"public_domain": result.get("public_domain", False),
"alias": result.get("alias", False),
"did_you_mean": result.get("did_you_mean", None)
}
else:
return {
"email": email,
"domain": "",
"mx": "Failed",
"disposable": "Failed",
"public_domain": "Failed",
"alias": "Failed",
"did_you_mean": None
}
# Function to process the CSV file
def process_emails(input_csv, output_csv, delay):
with open(input_csv, mode='r', newline='') as infile, open(output_csv, mode='w', newline='') as outfile:
reader = csv.reader(infile)
writer = csv.writer(outfile)
# Write header for the output file
writer.writerow(["Email", "Domain", "MX", "Disposable", "Public Domain", "Alias", "Did You Mean"])
# Process each email in the input file
for row in reader:
email = row[0]
result = check_email(email)
writer.writerow([result["email"], result["domain"], result["mx"], result["disposable"], result["public_domain"], result["alias"], result["did_you_mean"]])
print(f"Checked {email}: {result}")
# Delay before the next request
time.sleep(delay)
# Input and output file paths
input_csv = "emails.csv"
output_csv = "email_status.csv"
request_interval = 2 # Interval in seconds between requests
# Run the process
process_emails(input_csv, output_csv, request_interval)
不过用postman调用了一下你这接口不用KEY也正常跑的,如果不用key requests.get的时候不加headers就好了
他报错有too many requests,最好设置个时间间隔time.sleep(2)
这玩意干啥的啊, 你替换
https://api.usercheck.com/email/[目标 email]?key= 网站 token
https://api.usercheck.com/email/[email protected]?key=[api_token]
这接口是干啥用的,没看明白
看着是 验证 email 是否是别名?
感谢佬友,我用AI吃吃你这代码,只能看到一点点
验证email是否正常
佬友目标email有几千、上万个。如果一个链接能搞定,那就太完美了。不过你这链接,也让我学习了
授人以鱼不如授人以鱼, 你多用用 CHAT
我有个txt, 里边一行一个的 email
我需要请求 "https://api.usercheck.com/email/[dst_email]?key=[api_token]" 这个接口
然后请求结果如下 """f
"status":200,
"email":"[email protected]",
"domain":"linux.do",
"mx":true,
"disposable":false,
"public_domain":false,
"alias":false,
"did_you_mean":null
}"""
需要提取字段 mx 是否 为true, 然后输出结果到 result.csv 吧. 你能给我 BAT 运行方法 和 sh 运行方法么
哪不对, 你就让他改么
ai_gen_bat
@echo off
setlocal enabledelayedexpansion
set "api_token=your_api_token_here"
set "input_file=emails.txt"
set "output_file=result.csv"
echo Email,MX > %output_file%
for /f "tokens=*" %%a in (%input_file%) do (
set "email=%%a"
curl -s "https://api.usercheck.com/email/!email!?key=%api_token%" > response.json
for /f "tokens=2 delims=:," %%b in ('findstr "mx" response.json') do (
set "mx=%%b"
set "mx=!mx: =!"
echo !email!,!mx! >> %output_file%
)
)
del response.json
echo 处理完成。结果已保存到 %output_file%
ai_gen_sh
#!/bin/bash
api_token="your_api_token_here"
input_file="emails.txt"
output_file="result.csv"
echo "Email,MX" > "$output_file"
while IFS= read -r email
do
response=$(curl -s "https://api.usercheck.com/email/$email?key=$api_token")
mx=$(echo "$response" | grep -o '"mx":\s*\w\+' | cut -d ':' -f2 | tr -d ' ')
echo "$email,$mx" >> "$output_file"
done < "$input_file"
echo "处理完成。结果已保存到 $output_file"
1 Like
授人以鱼不如授人以渔 感谢佬友,我也一直在问,就是没你问的这么切入重点