搞定后的成果:
![]() | 1 yexiaoxing 2017-04-26 15:34:38 +08:00 request 的时候直接用 IP 替代 dns.google.com ,然后加上一个 HOST: dns.google.com 的 header ? |
![]() | &nbp; 2 denghongcai 2017-04-26 15:35:57 +08:00 ![]() 先用 dnspython 去查 ip ,然后给 urllib 设置 Host 头,用 IP 去请求就好了 |
![]() | 3 qinc 2017-04-26 15:44:16 +08:00 dnspod 家的 httpdns 貌似可以解决 |
![]() | 4 leavic OP @denghongcai urllib 对付 http 请求这样搞是可以,不过用 aiohttp 请求 https://dns.google.com 的时候就会爆 ssl 错误,还要看看。 |
![]() | 5 denghongcai 2017-04-26 17:59:01 +08:00 ![]() ssl 握手包里有域名,这样确实不行 自定义一个 connector 应该可以 http://aiohttp.readthedocs.io/en/stable/_modules/aiohttp/connector.html |
![]() | 6 TJT 2017-04-27 00:18:19 +08:00 简单粗暴的方法,起个 dnsmasq 中转 DNS 查询,然后 Python 用 dnspython 去查 IP ,查到就更新到 dnsmasq 里面,再去请求就好了。 不过正确的实现像五楼说的那样。 |
![]() | 7 TJT 2017-04-27 00:18:54 +08:00 不过正确的实现*应该*像五楼说的那样。 |
![]() | 9 andrewhxism 2017-04-27 10:16:39 +08:00 @leavic 不可能的,基本网络连接也需要初始 DNS 的 |
![]() | 10 leavic OP @andrewhxism 别扯,我已经搞定了。 |
![]() | 11 leavic OP @andrewhxism 好吧,我错了,好像还是有问题。 |
![]() | 12 leavic OP @andrewhxism 哈哈哈,是我代码写错了,还是可以的。 |
![]() | 14 candane 2017-04-27 13:50:43 +08:00 楼主搞定了没有?? |