<page> <domains> <domain> <name>example-site.ru</name> <response> <record domain="example-site.ru" priority="" ttl="21600" subdomain="@" type="A" id="23232301">3.5.7.9</record> <record domain="www.example-site.ru" priority="" ttl="21600" subdomain="www" type="A" id="23232302">3.5.7.9</record> </response> </domain> <error>ok</error> </domains> </page>
use LWP::UserAgent; my $hostout = `host example.dlinkddns.com`; // if ($hostout =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) { my $ip = "$1.$2.$3.$4"; #: open (FILE,"my_ip.txt"); my @lines = <FILE>; $old_ip = $lines[0]; # IP $old_ip =~ s/^\s+|\s+$//g; #trim close(FILE); if ($old_ip eq $ip) { die "IP not changed"; # , IP } open (FILE,">my_ip.txt"); print FILE $ip; # IP close(FILE); my $token = "gjkgwrth34wjh45kj2th234jkht34234lkj5"; my $domain00 = "example-site.ru"; my $id00 = "23232301"; my $subdomain01 = "www"; my $id01 = "23232302"; my $url00 ="https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=$token&domain=$domain00&record_id=$id00&content=$ip"; my $url01 ="https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=$token&domain=$domain00&subdomain=$subdomain01&record_id=$id01&content=$ip"; my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ); my $response = $ua->get($url00); if ( $response->is_success ) { print $response->decoded_content; } else { die $response->status_line; } my $response = $ua->get($url01); if ( $response->is_success ) { print $response->decoded_content; } else { die $response->status_line; } }
Source: https://habr.com/ru/post/239465/
All Articles