以下是Python代码,可以批量查询域名的标题:

import requests
from bs4 import BeautifulSoup

# 读取域名列表
with open('domains.txt', 'r') as f:
    domains = [line.strip() for line in f]

# 遍历域名列表,查询标题
for domain in domains:
    url = f'http://{domain}'
    try:
        response = requests.get(url, timeout=5)
        soup = BeautifulSoup(response.content, 'html.parser')
        title = soup.find('title').text.strip()
        print(f'{domain} - {title}')
    except:
        print(f'{domain} - Error')

将需要查询的域名列表保存在一个文本文件中,每行一个域名,命名为domains.txt,放在同一目录下。运行以上代码,即可输出每个域名的标题。如果查询出错,输出Error


原文地址: https://www.cveoy.top/t/topic/bJUI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录