YuzhenQin 2020-03-22 18:37 采纳率: 0%
浏览 8410

我的python程序一直出现getaddrinfo failed

# -*- coding: UTF-8 -*-
#导入包
import os,sys
import poplib
import threading,time
#程序启动时定义的变量
running_path = os.getcwd()    #获取工作空间
auto_server  = 'pop3'          #自动查找主机名1
pop_port     = 995
#定义函数
def print_menu():
    print('--------------------------------------------------------------------------------------------------------------------------------QYZ邮箱登录工具--------------------------------------------------------------------------------------------------------------------------------')
    return 0
def login(thread,host,account,password,ssl,debug):
    print(host)
    email_server = poplib.POP3_SSL(host=host, port=pop_port, timeout=0)
    try:
        if ssl=='y':
            email_server = poplib.POP3_SSL(host=host, port=pop_port, timeout=2)
        else:
            email_server = poplib.POP3(host=host, port=pop_port, timeout=2)
        print('[线程'+str(thread)+']','连接到'+host+':'+str(pop_port)+'成功')
    except:
        print('[线程'+str(thread)+']','无法连接到POP3服务器'+host+':'+str(pop_port))
        email_server.close()
        return 1
    try:
        email_server.user(account)
        print('[线程'+str(thread)+']','邮箱'+account+'存在')
    except:
        print('[线程'+str(thread)+']','邮箱'+account+'不存在')
        email_server.close()
        return 2
    try:
        email_server.pass_(password)
        print('[线程'+str(thread)+']','邮箱'+account+'密码正确!!')
    except:
        print('[线程'+str(thread)+']','邮箱'+account+'密码不正确')
        email_server.close()
        return 3
    email_server.close()
def get_host(account):
    length = len(account)
    host   = ''
    brelen = 0
    for i in range(0,length):
        if account[i]=='@':
            brelen = i
            break;
    for i in range(brelen+1,length):
        host = host + account[i]
    return host
def get_account(combo):
    ret = []
    length = len(combo)
    brelen = 0
    account = ''
    password = ''
    for i in range(0,length):
        if combo[i]==':':
            brelen = i
            break
        account = account + combo[i]
    ret.append(account)
    for i in range(brelen+1,length):
        password = password + combo[i]
    ret.append(password)
    return ret
def athread(thread,combo,ssl,debug):
    return login(thread,(auto_server+'.'+get_host(get_account(combo)[0])),get_account(combo)[0],get_account(combo)[1],ssl,debug)
#主程序
os.system('con cols=271 lines=71')
os.system('cls')
print_menu()
isssl = input('|使用SSL/TlS加密?  (y/n)')
combop= input('|输入combo的相对路径路径:')
combo = open(running_path + '\\' +combop,'r',encoding='utf-8')
combo.seek(0)
debug = input('|使用调试模式?     (y/n)')
thread= input('|使用的线程数           :')
threas= []
for i in range(0,int(thread)):
    threas.append(threading.Thread(target=athread,args=(i+1,combo.read(),isssl,debug)))
print('开始检测')
for i in range(0,int(thread)-1):
    threas[i].start()
threas[int(thread)-1].start()
threas[int(thread)-1].join()
combo.close()

图片说明

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-03-22 21:19
    关注

    服务器地址没有写对
    服务器不稳定
    你的dns或者网络设置的问题
    ssl证书问题
    或者你频繁访问服务器把你拉黑了。

    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错