python-3.x - python3 UnicodeError:使用“idna”编解码器编码失败(UnicodeError:标签为空或太长)
问题描述
我在运行我的程序时遇到了一些问题。我有一个“主文件”,它在 \n 上有一个 ips 列表,就像这样,但我不断收到此错误消息:
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)
解决方案
推荐阅读
- fabricjs - 执行 Object.fabric.parseSVGDocument 时抛出错误
- javascript - 计算鼠标和 DOM 元素边缘之间的距离
- javascript - Ajax 和 PHPMailer 错误
- java - 在 Java 中给出真实的路径
- python - 二叉树中的交替级顺序遍历
- eclipse - Xtext - 运行我的语法
- geocoding - google places api中地址组件的顺序
- unity3d - unity devide 预制件
- r - R,ggplot:“离散化”连续向量
- python - Altair/Vega-Lite 刻度图:从聚合字段中过滤前 K 条