Perl uses the Dnspod API to get the resolution of each region of the domain name

Source: Internet
Author: User

Tag:dnspod   dns   api    parsing    perl    

#!/usr/bin/perluse strict;use warnings;use lwp::useragent;use json;use encode;my   $mail = ' user ';my  $pass = ' pass ';my  $domain _info_url= ' https://dnsapi.cn/Domain.Info '; my $ Record_list_url= ' https://dnsapi.cn/Record.List '; sub get_domain_id {## #获取数据my   ($domain) [email  protected]_;my  $UA  = LWP::UserAgent->new; $UA->default_header (  ' user-agent '  =>  ' test dns client/1.0.0  ([email protected]) '  ];my  $response   =  $UA->post (  $domain _info_url, [  ' login_email '  =>  "$mail", ' Login_password '  =>  $pass ', ' format '  =>  ' json ', ' domain '  =>  ' $domain ']  );my  @string  =  $response->content;## #利用JSON   processing data my  $json _obj;my  $json  = new JSON;foreach  (@string) {$json _obj =  $json->decode ("$_");} return  $json _obj->{' domain '}->{' id '}; sub get_record_list {my  ($domain _id, $sub _domain) [email protected]_;my  $UA  = LWP ::useragent->new; $UA->default_header (  ' user-agent '  =>  ' test dns client/1.0.0   ([email protected]) '  ;my  $response   =  $UA->post (  $record _list_url , [  ' login_email '  =>  ' $mail ', ' Login_password '  =>  ' $pass ', ' format '  = >  ' json ', "domain_id"  =>  "$domain _id", "Sub_domain"  =>  "$sub _domain"] ); return  $response->content;} my  $json _obj;my  $json  = JSON->new->utf8;foreach  (get_record_list (get_domain_id ( "Main_domain.com"), "test") {     $json _obj =  $json->decode ("$_");} # # #main_domain. com primary domain name, test two-level domain name my  ($cast, @t);for my  $item (@{$json _obj->{' Records '}}) {    $cast  =  $item->{' ttl '} .  ' _ '  .  $item->{' line '}  .  "_"  .  $item->{' value '};  push  (@t, $cast);} # # # # #此处可以获取的值:           #              "id":  "744",#              "name":  "Hot",#              "line":  "Default",#             "type":   "A",#             "ttl":  ",# "             "value":  "1.1.1.1",#              "MX":  "0",#              "Enabled":  "1",#              "status":  "Enabled", #             "Monitor_status":  "",#              "Remark":  "",#              "updated_on":  "2014-07-30 12:38:44",#              "USE_AQB":  "no"            foreach  (@t) {my  $re  = encode ("gb2312", $_);    print  " $re \ n ";}

The above is a Perl I wrote, just started to write a little messy.

This article is from the "perling" blog, make sure to keep this source http://zhaolin.blog.51cto.com/9397923/1586357

Perl uses the Dnspod API to get the resolution of each region of the domain name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.