{"id":6483,"date":"2014-07-17T21:21:46","date_gmt":"2014-07-17T13:21:46","guid":{"rendered":"http:\/\/jpuyy.com\/?p=6483"},"modified":"2014-07-17T21:22:23","modified_gmt":"2014-07-17T13:22:23","slug":"managing-dns-with-python","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=6483","title":{"rendered":"python\u7ba1\u7406dns"},"content":{"rendered":"<p>\u4f7f\u7528dnspython\u6a21\u5757<\/p>\n<pre>pip install dnspython<\/pre>\n<p>\u67e5\u8be2A\u8bb0\u5f55<\/p>\n<pre>\r\nimport dns.resolver\r\nip = dns.resolver.query(\"jpuyy.com\", \"A\")\r\nfor i in ip:\r\n    print i<\/pre>\n<p>\u5199\u4e2a\u51fd\u6570\u67e5\u8be2\u591a\u6761\u8bb0\u5f55<\/p>\n<pre>#!\/usr\/bin\/env python\r\n#-*- coding:utf-8 -*-\r\n\r\nimport dns.resolver\r\n\r\nhosts = [\"jpuyy.com\", \"hupu.com\", \"hao123.com\", \"ifeng.com\"]\r\n\r\ndef query(host_list = hosts):\r\n    collection = []\r\n    for host in host_list:\r\n        ip  =  dns.resolver.query(host,\"A\")\r\n        for i in ip:\r\n            collection.append(str(i))\r\n    return collection\r\n\r\nif __name__ == \"__main__\":\r\n    for arec in query():\r\n        print arec\r\n<\/pre>\n<p>\u6765\u81eapython for unix and linux system Administration<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528dnspython\u6a21\u5757 pip install dnspython \u67e5\u8be2A\u8bb0\u5f55 import dns.resolver ip = dns.resolver.query(&#8220;jpuyy.com&#8221;, &#8220;A&#8221;) for i in ip: print i \u5199\u4e2a\u51fd\u6570\u67e5\u8be2\u591a\u6761\u8bb0\u5f55 #!\/usr\/bin\/env python #-*- coding:utf-8 -*- import dns.resolver hosts = [&#8220;jpuyy.com&#8221;, &#8220;hupu.com&#8221;, &#8220;hao123.com&#8221;, &#8220;ifeng.com&#8221;] def query(host_list = hosts): collection = [] for host in host_list: ip = dns.resolver.query(host,&#8221;A&#8221;) for i in ip: collection.append(str(i)) return collection if __name__ == [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-6483","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6483"}],"version-history":[{"count":6,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6483\/revisions"}],"predecessor-version":[{"id":6489,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6483\/revisions\/6489"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}