Hongmu Notes
Home Language Notes Python image query to remove duplicates and detect whether the file exists
Language Notes python

Python image query to remove duplicates and detect whether the file exists

Python image query to remove duplicates and detect whether the file exists

Self-use script, keep it for backup

import os
import re

# ---------- 配置 ----------
ok_dir = r"C:\Users\18102\Downloads\ok"
output_missing = "missing.txt"  # 输出到当前脚本所在目录

# ---------- 生成所有目标域名 (aaa0001.com ~ aaa1167.com) ----------
expected_domains = set()
for i in range(1, 1168):  # 0001 到 1167
    domain = f"aaa{i:04d}.com"
    expected_domains.add(domain)

# ---------- 获取 ok 文件夹中已存在的截图域名 ----------
existing_domains = set()
if os.path.exists(ok_dir):
    for filename in os.listdir(ok_dir):
        if filename.lower().endswith('.png'):
            base = os.path.splitext(filename)[0]
            # 去除可能存在的 "(序号)" 后缀(如 "aaa0001 (1)")
            match = re.match(r'^(.*?)(?:\s*\(\d+\))?$', base)
            if match:
                domain = match.group(1)
                existing_domains.add(domain)
else:
    print(f"⚠️ 警告:{ok_dir} 目录不存在,请确认路径。")

# ---------- 计算缺失的域名 ----------
missing_domains = expected_domains - existing_domains

# ---------- 输出缺失的原始访问链接 ----------
with open(output_missing, 'w', encoding='utf-8') as f:
    for domain in sorted(missing_domains):
        url = f"http://aaa001.com/?url=http://{domain}"
        f.write(url + '\n')

print(f"✅ 缺失的网址已保存到 {output_missing}")
print(f" 共缺失 {len(missing_domains)} 个。")

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Import " requests" could not be resolved from source

Import " requests" could not be resolved from source Language Notes python

This error occurred when using Pylance, a Python language server. Among them, " Import " requests" could not be resolved from source" This error message indicates that the requests module is referenced in your code, but Pylance cannot find the location of the module from the source. The possible reason is that you don't have an …
👁 1771
Reinstall Python and requests libraries

Reinstall Python and requests libraries Language Notes python

If you meet " Import " requests" could not be resolved from source" You can try reinstalling Python and requests libraries. First, you need to uninstall the current Python and requests libraries. On Windows systems, you can use the command prompt …
👁 439
WARNING: Skipping requests as it is not installed.

WARNING: Skipping requests as it is not installed. Language Notes python

This error message indicates that your Python environment lacks the requests library, and this library is called in your code, so Python cannot execute your code normally. The solution to this problem is to install the requests library. You can use the pip command on the command line to install: pip install requests If you are using Python3, you can use the pip3 command …
👁 2100
Python reported an error. What is the reason? AttributeError: partially initialized module ' openai'  has no attribute ' Completion' (most likely due to a circular import)

Python reported an error. What is the reason? AttributeError: partially initialized module ' openai' has no attribute ' Completion' (most likely due to a circular import) Language Notes python

This error prompt indicates that there is a problem when importing the openai module and the specific Completion attribute, which is probably caused by circular import. The reason for this error may be that two or more modules in your code are imported from each other, forming a circular dependency. For example, module A imports module B, and module B imports module A.. Cyclic import will cause the module not to initialize correctly when loading, thus …
👁 656
How does python package and run on Windows?

How does python package and run on Windows? Language Notes python

The most common way to package and run Python programs on Windows is to use PyInstaller. PyInstaller is a free and cross-platform Python application packaging tool, which can package Python code and its dependent libraries into an independent executable file, making it possible to run Python programs on systems without Python interpreters installed. The following is to make …
👁 300
What programming software is good for python development?

What programming software is good for python development? Language Notes python

There are many programming softwares developed by Python. The following are some commonly used Python integrated development environments (IDE) and editors: PyCharmPyCharm is an integrated development environment developed by JetBrains, which is specially designed for Python developers. PyCharm is powerful and provides a series of advanced functions such as code completion, debugging, version control, code refactoring, etc., which can help developers improve their work …
👁 175

Recommended reading

(Adaptive Mobile Version) Large-screen, professional water purification device website – PBootCMS template; Smart electronic device website source code download – 0435

(Adaptive Mobile Version) Large-screen, professional water purification device website – PBootCMS template; Smart electronic device website source code download – 0435 Practical Collection pbootcms Template

This set includes an adaptive, wide-screen water purification system for mobile devices and a smart electronic device – PbootCMS website template. The modern, tech-driven design is ideal for showcasing water purification products, smart hardware, and related solutions. It helps water purification brands effectively present their products online and attract both residential and commercial customers. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.c...
👁 32
(Adaptive mobile terminal) personal blog website template news information articles website source download 0991

(Adaptive mobile terminal) personal blog website template news information articles website source download 0991 Practical Collection pbootcms Template

A personal blog and news information article class PbootCMS website template, support mobile terminal access. The design style is simple to read, suitable for personal bloggers or information websites to publish articles. It is the basic choice for content creators to build a personal writing platform. Template display, installation instructions website background: / admin.php account: admin password: admin decompression password: www.4s5.cn related article PbootCM...
👁 55
Responsive infant early education enlightenment website template 0388

Responsive infant early education enlightenment website template 0388 Practical Collection Yiyou template

A eyoucms responsive website template for the infant early education enlightenment industry. The design style is lively and childlike fun, which can show the early education enlightenment course, teaching environment, teachers and educational concept. It will help early education agencies to attract parents online and enhance their brand awareness. Template display, installation instructions website background: / login.php account: admin password: admin related article easy you CMS installation FAQ summary easy you...
👁 40
Responsive boutique leather goods high-end luggage website template 0979

Responsive boutique leather goods high-end luggage website template 0979 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the premium leather goods and high-end luggage industry. Its sophisticated and fashionable design perfectly showcases leather goods products, brand stories, design concepts, and customisation services. It enables leather goods brands to showcase their products online and attract consumers who value a quality lifestyle. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 46
(Adaptive Mobile Version) Mechanical Manufacturing Website – PBootCMS Template; Blue Industrial Machinery and Equipment Website Source Code Download – 0436

(Adaptive Mobile Version) Mechanical Manufacturing Website – PBootCMS Template; Blue Industrial Machinery and Equipment Website Source Code Download – 0436 Practical Collection pbootcms Template

An adaptive mobile-friendly PbootCMS website template designed for mechanical manufacturing and blue-collar industrial machinery enterprises, ideal for showcasing their product ranges. It helps machinery companies build an online brand presence and attract industrial clients. Template Overview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 62