﻿{"id":1406,"date":"2019-06-23T14:42:16","date_gmt":"2019-06-23T06:42:16","guid":{"rendered":"https:\/\/www.tansoo.cn\/?p=1406"},"modified":"2019-06-23T14:42:16","modified_gmt":"2019-06-23T06:42:16","slug":"phpbb-4","status":"publish","type":"post","link":"https:\/\/www.tansoo.cn\/?p=1406","title":{"rendered":"\u901a\u8fc7python\u52a8\u6001\u66f4\u65b0\u963f\u91cc\u4e91DNS\u89e3\u6790\uff0c\u4f5c\u4e3aDDNS\u4f7f\u7528"},"content":{"rendered":"<p>\u82b19\u5143\u94b1\u5728\u963f\u91cc\u4e91\u4e0a\u4e91\u6ce8\u518c\u4e00\u4e2a\u201c.top\u201d\u7684\u9876\u7ea7\u57df\u540d\uff0c\u518d\u5229\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u5b9a\u65f6\u66f4\u65b0\u4f60\u5bb6\u8def\u7531\u5668\u7684IP\uff0c\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86DDNS\u7684\u6548\u679c\u4e86\u3002<br \/>\n\u4e0b\u9762Python\u4ee3\u7801\u4e2d\u7684AcsClient\uff08\uff09\u3001request.set_RecordId(&#8220;17741030***760&#8221;)\u8fd9\u4e24\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u8bf7\u5728https:\/\/help.aliyun.com\/document_detail\/53090.html \u4e0a\u67e5\u770b\u3002<\/p>\n<div class=\"codebox_plus_wrap\">\n<div class=\"codebox_plus_header\"><strong>Code: <\/strong><a href=\"#\" onclick=\"codebox_plus_select(this, 1); return false;\">[\u5168\u9009]<\/a>&nbsp;<a href=\"#\" onclick=\"codebox_plus_toggle(this, 1); return false;\">[Expand\/Collapse]<\/a><\/div>\n<div>\n<div style=\"display: inline;\">\n<div class=\"python\" style=\"font-family:monospace;\">\n<ol>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">#!\/usr\/bin\/env python<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">#coding=utf-8<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">import<\/span> json<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">import<\/span> <span style=\"color: #dc143c;\">urllib<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">import<\/span> <span style=\"color: #dc143c;\">datetime<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">from<\/span> aliyunsdkcore.<span style=\"color: black;\">client<\/span> <span style=\"color: #ff7700;font-weight:bold;\">import<\/span> AcsClient<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">from<\/span> aliyunsdkcore.<span style=\"color: black;\">acs_exception<\/span>.<span style=\"color: #dc143c;\">exceptions<\/span> <span style=\"color: #ff7700;font-weight:bold;\">import<\/span> ClientException<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">from<\/span> aliyunsdkcore.<span style=\"color: black;\">acs_exception<\/span>.<span style=\"color: #dc143c;\">exceptions<\/span> <span style=\"color: #ff7700;font-weight:bold;\">import<\/span> ServerException<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">from<\/span> aliyunsdkalidns.<span style=\"color: black;\">request<\/span>.<span style=\"color: black;\">v20150109<\/span>.<span style=\"color: black;\">DescribeDomainRecordInfoRequest<\/span> <span style=\"color: #ff7700;font-weight:bold;\">import<\/span> DescribeDomainRecordInfoRequest<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">from<\/span> aliyunsdkalidns.<span style=\"color: black;\">request<\/span>.<span style=\"color: black;\">v20150109<\/span>.<span style=\"color: black;\">UpdateDomainRecordRequest<\/span> <span style=\"color: #ff7700;font-weight:bold;\">import<\/span> UpdateDomainRecordRequest<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">client <span style=\"color: #66cc66;\">=<\/span> AcsClient<span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&#8216;LTAIjOE53h******fI&#8217;<\/span><span style=\"color: #66cc66;\">,<\/span> <span style=\"color: #483d8b;\">&#8216;JlvkmaCPek3SqqY*******GQbd8Zp&#8217;<\/span><span style=\"color: #66cc66;\">,<\/span> <span style=\"color: #483d8b;\">&#8216;cn-hangzhou&#8217;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">request <span style=\"color: #66cc66;\">=<\/span> DescribeDomainRecordInfoRequest<span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">request.<span style=\"color: black;\">set_accept_format<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&#8216;json&#8217;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">request.<span style=\"color: black;\">set_RecordId<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&quot;17741030***760&quot;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">response <span style=\"color: #66cc66;\">=<\/span> client.<span style=\"color: black;\">do_action_with_exception<\/span><span style=\"color: black;\">&#40;<\/span>request<span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">response <span style=\"color: #66cc66;\">=<\/span> json.<span style=\"color: black;\">loads<\/span><span style=\"color: black;\">&#40;<\/span>response.<span style=\"color: black;\">decode<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">old_ip <span style=\"color: #66cc66;\">=<\/span> response<span style=\"color: black;\">&#91;<\/span><span style=\"color: #483d8b;\">&#8216;Value&#8217;<\/span><span style=\"color: black;\">&#93;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">new_ip <span style=\"color: #66cc66;\">=<\/span> <span style=\"color: #dc143c;\">urllib<\/span>.<span style=\"color: black;\">urlopen<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&quot;http:\/\/ip.42.pl\/raw&quot;<\/span><span style=\"color: black;\">&#41;<\/span>.<span style=\"color: black;\">read<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">if<\/span> old_ip <span style=\"color: #66cc66;\">!=<\/span> new_ip:<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request <span style=\"color: #66cc66;\">=<\/span> UpdateDomainRecordRequest<span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request.<span style=\"color: black;\">set_accept_format<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&#8216;json&#8217;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request.<span style=\"color: black;\">set_Value<\/span><span style=\"color: black;\">&#40;<\/span>new_ip<span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request.<span style=\"color: black;\">set_Type<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&quot;A&quot;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request.<span style=\"color: black;\">set_RR<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&quot;nas&quot;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; request.<span style=\"color: black;\">set_RecordId<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: #483d8b;\">&quot;17741030***760&quot;<\/span><span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; response <span style=\"color: #66cc66;\">=<\/span> client.<span style=\"color: black;\">do_action_with_exception<\/span><span style=\"color: black;\">&#40;<\/span>request<span style=\"color: black;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; <span style=\"color: #ff7700;font-weight:bold;\">print<\/span> <span style=\"color: #dc143c;\">datetime<\/span>.<span style=\"color: #dc143c;\">datetime<\/span>.<span style=\"color: black;\">now<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><span style=\"color: #66cc66;\">,<\/span><span style=\"color: #483d8b;\">&#8216; &#8216;<\/span><span style=\"color: #66cc66;\">,<\/span> old_ip<span style=\"color: #66cc66;\">,<\/span> <span style=\"color: #483d8b;\">&#8216; =&gt; &#8216;<\/span><span style=\"color: #66cc66;\">,<\/span> new_ip <\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #ff7700;font-weight:bold;\">else<\/span> :<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; <span style=\"color: #ff7700;font-weight:bold;\">print<\/span> <span style=\"color: #dc143c;\">datetime<\/span>.<span style=\"color: #dc143c;\">datetime<\/span>.<span style=\"color: black;\">now<\/span><span style=\"color: black;\">&#40;<\/span><span style=\"color: black;\">&#41;<\/span><span style=\"color: #66cc66;\">,<\/span><span style=\"color: #483d8b;\">&#8216; IP has not changed.&#8217;<\/span><span style=\"color: #66cc66;\">,<\/span> new_ip<\/div>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"codebox_plus_footer\">GeSHi &copy; Codebox Plus Extension<\/div>\n<\/div>\n<p><small>\u539f\u6587\u4f5c\u8005: admin | <a href=\"https:\/\/bbs.tansoo.cn\/viewtopic.php?t=4\" target=\"_blank\" rel=\"noopener\">\u67e5\u770b\u539f\u5e16<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u82b19\u5143\u94b1\u5728\u963f\u91cc\u4e91\u4e0a\u4e91\u6ce8\u518c\u4e00\u4e2a\u201c.top\u201d\u7684\u9876\u7ea7\u57df\u540d\uff0c\u518d\u5229\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u5b9a\u65f6\u66f4\u65b0\u4f60\u5bb6 &hellip; <a href=\"https:\/\/www.tansoo.cn\/?p=1406\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[104],"tags":[],"class_list":["post-1406","post","type-post","status-publish","format-standard","hentry","category-104"],"_links":{"self":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/1406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1406"}],"version-history":[{"count":0,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/1406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}