import requests
# 发送请求
response = requests.get('https://www.cqxkj.top/sitemap.txt')
print(response.status_code)
data = response.text
# 保存sitemap.txt文件
with open('sitemap.txt', 'w', encoding='utf-8') as f:
f.write(data)
# 读取sitemap.txt文件内容,并分割成数组
data_array = response.text.split('\n')
# 定义函数,将数组中的数据添加双引号,并写入到 output.txt 文件中
def add_quotes(data):
quoted_data = ""
for item in data:
quoted_data += f'"{item}",\n'
# 写入文件
with open('output.txt', 'w', encoding='utf-8') as f:
f.write(quoted_data)
return quoted_data
# 调用函数
print(add_quotes(data_array))
上面代码可以将,网站的sitemap.txt,切分加引号。同时导出到txt中
# 源文件
https://www.cqxkj.top
https://www.cqxkj.top/aboutus/
https://www.cqxkj.top/article/
https://www.cqxkj.top/service/
https://www.cqxkj.top/service/18.html
https://www.cqxkj.top/service/19.html
https://www.cqxkj.top/service/20.html
https://www.cqxkj.top/service/21.html
https://www.cqxkj.top/service/22.html
https://www.cqxkj.top/service/23.html
https://www.cqxkj.top/service/24.html
https://www.cqxkj.top/service/25.html
# 转换后的
"https://www.cqxkj.top/industry/112.html",
"https://www.cqxkj.top/industry/113.html",
"https://www.cqxkj.top/industry/114.html",
"https://www.cqxkj.top/industry/115.html",
"https://www.cqxkj.top/industry/116.html",
"https://www.cqxkj.top/industry/122.html",
"https://www.cqxkj.top/industry/123.html",
"https://www.cqxkj.top/industry/124.html",
"https://www.cqxkj.top/industry/125.html",
"https://www.cqxkj.top/industry/126.html",
转换后,通过bing indexnow,发送http请求,就可以批量 提交url,代码如下
POST https://api.indexnow.org/IndexNow HTTP/1.1
Content-Type: application/json; charset=utf-8
{
"host": "www.cqxkj.top",
"key": "自己的key",
"urlList": [
"https://www.cqxkj.top",
"https://www.cqxkj.top/aboutus/",
"https://www.cqxkj.top/article/",
"https://www.cqxkj.top/service/",
"https://www.cqxkj.top/service/18.html",
"https://www.cqxkj.top/service/19.html",
"https://www.cqxkj.top/service/20.html",
"https://www.cqxkj.top/service/21.html",
"https://www.cqxkj.top/service/22.html",
"https://www.cqxkj.top/service/23.html",
"https://www.cqxkj.top/service/24.html",
"https://www.cqxkj.top/service/25.html",
"https://www.cqxkj.top/contact/",
"https://www.cqxkj.top/company/",
"https://www.cqxkj.top/company/4.html",
"https://www.cqxkj.top/company/8.html",
"https://www.cqxkj.top/company/28.html",
"https://www.cqxkj.top/company/30.html",
"https://www.cqxkj.top/company/31.html",
"https://www.cqxkj.top/company/36.html",
"https://www.cqxkj.top/company/37.html",
"https://www.cqxkj.top/company/38.html",
"https://www.cqxkj.top/company/39.html",
"https://www.cqxkj.top/company/40.html",
"https://www.cqxkj.top/company/41.html",
"https://www.cqxkj.top/company/44.html",
"https://www.cqxkj.top/company/45.html",
"https://www.cqxkj.top/company/46.html",
"https://www.cqxkj.top/company/47.html",
"https://www.cqxkj.top/company/58.html",
"https://www.cqxkj.top/company/59.html",
"https://www.cqxkj.top/company/60.html",
"https://www.cqxkj.top/company/61.html",
"https://www.cqxkj.top/company/62.html",
"https://www.cqxkj.top/company/63.html",
"https://www.cqxkj.top/company/64.html",
"https://www.cqxkj.top/company/65.html",
"https://www.cqxkj.top/company/66.html",
"https://www.cqxkj.top/company/67.html",
"https://www.cqxkj.top/company/73.html",
"https://www.cqxkj.top/company/74.html",
"https://www.cqxkj.top/company/75.html",
"https://www.cqxkj.top/company/76.html",
"https://www.cqxkj.top/company/77.html",
"https://www.cqxkj.top/company/83.html",
"https://www.cqxkj.top/company/84.html",
"https://www.cqxkj.top/company/85.html",
"https://www.cqxkj.top/company/86.html",
"https://www.cqxkj.top/company/87.html",
"https://www.cqxkj.top/company/88.html",
"https://www.cqxkj.top/company/90.html",
"https://www.cqxkj.top/company/92.html",
"https://www.cqxkj.top/company/94.html",
"https://www.cqxkj.top/company/96.html",
"https://www.cqxkj.top/company/97.html",
"https://www.cqxkj.top/company/98.html",
"https://www.cqxkj.top/company/99.html",
"https://www.cqxkj.top/company/100.html",
"https://www.cqxkj.top/company/101.html",
"https://www.cqxkj.top/industry/",
"https://www.cqxkj.top/industry/5.html",
"https://www.cqxkj.top/industry/6.html",
"https://www.cqxkj.top/industry/7.html",
"https://www.cqxkj.top/industry/26.html",
"https://www.cqxkj.top/industry/27.html",
"https://www.cqxkj.top/industry/29.html",
"https://www.cqxkj.top/industry/32.html",
"https://www.cqxkj.top/industry/33.html",
"https://www.cqxkj.top/industry/34.html",
"https://www.cqxkj.top/industry/35.html",
"https://www.cqxkj.top/industry/42.html",
"https://www.cqxkj.top/industry/43.html",
"https://www.cqxkj.top/industry/48.html",
"https://www.cqxkj.top/industry/49.html",
"https://www.cqxkj.top/industry/50.html",
"https://www.cqxkj.top/industry/51.html",
"https://www.cqxkj.top/industry/52.html",
"https://www.cqxkj.top/industry/53.html",
"https://www.cqxkj.top/industry/54.html",
"https://www.cqxkj.top/industry/55.html",
"https://www.cqxkj.top/industry/56.html",
"https://www.cqxkj.top/industry/57.html",
"https://www.cqxkj.top/industry/68.html",
"https://www.cqxkj.top/industry/69.html",
"https://www.cqxkj.top/industry/70.html",
"https://www.cqxkj.top/industry/71.html",
"https://www.cqxkj.top/industry/72.html",
"https://www.cqxkj.top/industry/78.html",
"https://www.cqxkj.top/industry/79.html",
"https://www.cqxkj.top/industry/80.html",
"https://www.cqxkj.top/industry/81.html",
"https://www.cqxkj.top/industry/82.html",
"https://www.cqxkj.top/industry/89.html",
"https://www.cqxkj.top/industry/91.html",
"https://www.cqxkj.top/industry/93.html",
"https://www.cqxkj.top/industry/95.html",
"https://www.cqxkj.top/industry/102.html",
"https://www.cqxkj.top/industry/103.html",
"https://www.cqxkj.top/industry/104.html",
"https://www.cqxkj.top/industry/105.html",
"https://www.cqxkj.top/industry/106.html",
]
}