python3 UnicodeError:使用“ idna”编解码器编码失败(UnicodeError:标签为空或过长)

时间:2019-01-28 17:58:55

标签: python-3.x unicode

我在运行程序时遇到一些问题。我有一个“主文件”,它在\ n上有一个ip列表,但我一直收到以下错误消息:

68.x.0.56
68.x.0.53

我不确定到底是什么问题,但是我一直在搜索论坛和其他stackoverflow帮助,但似乎无法确定问题所在。

def dns_resolver(subdomains):
    print('\n\n########## Checking Subdomains for DNS Resolutions ##########\n')
    queries = []
    with open ('masterfile', 'r') as f:
        domains = f.read().splitlines()
        for i in domains:
            try:
                resp = socket.gethostbyname(i)
                print(resp)
                queries.append((i, resp))
            except socket.error:
                pass
    return queries

Traceback (most recent call last):
  File "/usr/lib/python3.6/encodings/idna.py", line 165, in encode
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "subdomain-hunter.py", line 170, in <module>
    main()
  File "subdomain-hunter.py", line 59, in main
    enumerate(DOMAIN)
  File "subdomain-hunter.py", line 120, in enumerate
    resolvediff = dns_resolver(diff)
  File "subdomain-hunter.py", line 142, in dns_resolver
    resp = socket.gethostbyname(i)
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

0 个答案:

没有答案