浙江省建设厅网站如何查安全员,宣传推广渠道有哪些,商河 网站建设,oa系统是什么系统没找到api#xff0c;托管到cloudflare也不行。就只能写代码了#xff08;只写了更新和添加单条ipv6记录#xff09; 需要修改的地方 请求头的cookies填自己的 data里的zone填自己的
import requests
from lxml import etree host#子域名
cookies填自己的
zone自己域名的
…没找到api托管到cloudflare也不行。就只能写代码了只写了更新和添加单条ipv6记录 需要修改的地方 请求头的cookies填自己的 data里的zone填自己的
import requests
from lxml import etree host#子域名
cookies填自己的
zone自己域名的
ipv6 requests.get(https://6.ipw.cn/).text#获取ipv6地址
print(本机ipv6地址:%s%ipv6)get_records_urlhttps://www.cloudns.net/ajaxPages.php?actionrecords
url https://www.cloudns.net/ajaxActions.php?actionrecords
headers {cookie:cookies,user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36}#获取记录
get_records {show: get,zone: zone,type: all,order-by: null,page: 1
}
#修改cname
update_data {
show: editRecord,
zone: zone,
record_id: ,
settings[host]: ,
settings[record]: ,
settings[ttl]: 3600
}
#添加aaaa
add_ipv6_data {show: addRecord,zone: zone,recordType: AAAA,active: 1,settings[host]: ,settings[record]: 2409:8a62:6421:f881:9d23:59d2:10b:b1d5,settings[ttl]: 3600
}response_records_table requests.post(get_records_url,headersheaders,dataget_records)#获取dns记录表格# print(response_records.text)tree etree.HTML(response_records_table.text)# 测试XPath表达式
record_host_path //*[idrecordsBody]/tr/td[2]/div/div/text()#主机
record_type_path //*[idrecordsBody]/tr/td[3]/text()#记录类型
record_value_path //*[idrecordsBody]/tr/td[4]/div/div/text()#值/指向到
record_id_path //*[idrecordsBody]/tr/id#id
record_host [host.strip() for host in tree.xpath(record_host_path)]
record_type [type.strip() for type in tree.xpath(record_type_path)]
record_value [value.strip() for value in tree.xpath(record_value_path)]
record_id [id.replace(row-,) for id in tree.xpath(record_id_path)]
# print(record_host)
# print(record_type)
# print(record_value)
# print(record_id)l len(record_type)
record_list {}#存放记录的字典列表
a 0
while a l:#做成类型对idhostvalue的字典列表record_list.setdefault(record_type[a],[]).append(record_id[a])record_list.setdefault(record_type[a],[]).append(record_host[a])record_list.setdefault(record_type[a],[]).append(record_value[a])a1# print(record_list)
# print(record_list[AAAA][0 ])def update_ipv6(ipv6,record_list,host): #更新ipv6记录(ipv6你的ipv6地址,host就是子域名留空不加)update_data[record_id] record_list[AAAA][0]update_data[settings[host]] hostupdate_data[settings[record]] ipv6print(update_data)response requests.post(url,headersheaders,dataupdate_data)try:if response.json()[status] 1:print(修改成功)print(response.status_code)else :print(response.text)print(失败,状态码错误)except:print(失败,停止运行)exit()def add_ipv6(ipv6,host): #ipv6你的ipv6地址,host就是子域名留空不加add_ipv6_data[recordType] AAAAupdate_data[settings[host]] hostupdate_data[settings[record]] ipv6print(add_ipv6_data)response requests.post(url,headersheaders,dataadd_ipv6_data)try:if response.json()[status] 1:print(添加成功)print(response.status_code)else :print(response.text)print(失败,状态码错误)except:print(失败,停止运行)exit()if AAAA in record_list:print(检测到已有ipv6地址记录)update_ipv6(ipv6ipv6,record_listrecord_list,hosthhhhh)
else: print(未检测到ipv6记录)add_ipv6(ipv6ipv6,host)