从域数据库中过滤过期域和注册域

问题描述

我有一个包含 100 万个域的数据库中的域列表。 我使用下面的 python 代码过滤掉两个不同 .csv 文件中当前注册的域和过期的域。

但是当我向域名注册查询时,注册域名列表中大约 15-20% 的域名已过期。

我正在考虑如何进一步改进我的代码。 在 whois 测试之后加入 ping 测试会提高准确性吗?

非常感谢建议...

import requests
import whois
import csv    
from csv import reader
import concurrent.futures
import tldextract

AllDomains = []

with open('raw-domains.csv','r') as f:
    reader = csv.reader(f)
    for row in reader:
        AllDomains.append(row[0])

def filterdomains (domainname):

        try:
            a=(tldextract.extract(domainname))
            host = a.registered_domain
            res = whois.whois(host)  # Check Whois info.

# save domain as registered if whois info found            
            with open('Registered-domains.csv','a',encoding="utf-8",newline='') as myfile:   
                        writer = csv.writer(myfile)
                        writer.writerow([host])
            print(host+"--Registered")
               
        except whois.parser.PywhoisError:

# save domain as expired if whois info is not available
            with open('Expired-domains.csv',newline='') as myfile:  
                        writer = csv.writer(myfile)
                        writer.writerow([host])
            print(host+"--Expired")
                        
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
        executor.map(filterdomains,AllDomains)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...