Last active
August 29, 2015 13:57
-
-
Save kenee/9596406 to your computer and use it in GitHub Desktop.
分析新网的域名解析列表页,生成符合dnspod导入格式的txt文件,这个txt文件可以用dnspod的[客户端](https://support.dnspod.cn/Support/api) 导入
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define("DOMAIN_NAME", 'mydomain.com'); | |
| $dnspod_header = "主机|类型|线路|记录值|MX优先级|TTL|备注\n"; | |
| $dnspod_content = ""; | |
| $xinnet_html = file_get_contents("o.txt"); | |
| preg_match('/<!-- ADDRESS RECORDS -->([\s\S]+)tbccname/',$xinnet_html,$ret); | |
| $a_html = $ret[1]; | |
| #echo $a_html; | |
| preg_match('/tbccname.+([\s\S]+)<!-- ================================================== -->/',$xinnet_html,$ret); | |
| $cname_html = $ret[1]; | |
| #echo $cname_html; | |
| preg_match_all('/name="rBo.name" value=([^"].+)>/',$a_html,$ret1); | |
| preg_match_all('/editrow\(tbca,\'[0-9]+\',\'(\d+.\d+.\d+.\d+)\',.+/',$a_html,$ret2); | |
| $ret_a = $ret1[1]; | |
| $ret_a_value = $ret2[1]; | |
| $ret1 = ''; | |
| $ret2 = ''; | |
| preg_match_all('/name="rBo.name" value="(.+)"\/>/',$cname_html,$ret1); | |
| preg_match_all('/editrow\(tbccname,\'[0-9]+\',\'([^\']+)\',.+/',$cname_html,$ret2); | |
| $ret_cname = $ret1[1]; | |
| $ret_cname_value = $ret2[1]; | |
| for($i=0;$i<count($ret_a);$i++){ | |
| $key = $ret_a[$i]; | |
| $key = str_replace(".".DOMAIN_NAME, '', $key); | |
| $value = $ret_a_value[$i]; | |
| $dnspod_a .= "{$key} A 默认 {$value} 0 600\n"; | |
| } | |
| for($i=0;$i<count($ret_cname);$i++){ | |
| $key = $ret_cname[$i]; | |
| $key = str_replace(".".DOMAIN_NAME, '', $key); | |
| $value = $ret_cname_value[$i]; | |
| $dnspod_cname .= "{$key} CNAME 默认 {$value}. 0 600\n"; | |
| } | |
| $all_in_one = $dnspod_header.$dnspod_a.$dnspod_cname; | |
| file_put_contents("dnspod_import.txt",$all_in_one); | |
| echo "parse xinnet html...ok"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment