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