In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to parse the raspberry pie plus python3 script to automatically report the ip to the Wanwang domain name. The article is rich and analyzed and described from a professional point of view. I hope you can get something after reading this article.
Dependence:
Raspberry pie 3b
Wanwang domain name (you need to apply for APIkey)
Python3 module:
Requests
Aliyun-python-sdk-core-v3
Aliyun-python-sdk-alidns
The script is as follows:
Import requestsimport jsonfrom aliyunsdkcore.client import AcsClientfrom aliyunsdkcore.acs_exception.exceptions import ClientExceptionfrom aliyunsdkcore.acs_exception.exceptions import ServerExceptionfrom aliyunsdkalidns.request.v20150109 import UpdateDomainRecordRequest, DescribeDomainRecordInfoRequestDOMAIN ='* .com'RID = 'rid'client = AcsClient ("appkey", "appsecret") of the domain name "cn-hangzhou") def ip (): # self-written get source IP service r = requests.get ('http://*.*.com/get/ip') if r.status_code = = 200: return r.text else: return Nonedef update_record (cip) Old): update_pi (cip) req = UpdateDomainRecordRequest.UpdateDomainRecordRequest () req.set_RecordId (RID) req.set_RR (old ['RR']) req.set_Type (old [' Type']) req.set_Value (cip) resp = client.do_action_with_exception (req) print (resp) return Truedef update_pi (cip): postdata = {'ip': ip} # write it yourself The web service for recording IP changes r = requests.post ('http://*.*.com/pi/ip', Data=postdata) return r.text = = 'ok'def connect_dns (): cip = ip () if not cip: return False req = DescribeDomainRecordInfoRequest.DescribeDomainRecordInfoRequest () req.set_RecordId (RID) resp = client.do_action_with_exception (req) .decode (' utf-8') old = json.loads (resp) if cip = old ['Value']: return True else: return update_record (cip) Old) if _ _ name__ = ='_ main__': connect_dns ()
It is then placed in crontab and executed every half hour to automatically detect and update.
The above is how to parse the raspberry pie plus python3 script to automatically report the ip to the Wanwang domain name. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.