Python扫描网站的目录

本文介绍了一个使用Python编写的简单网站目录扫描程序。该程序通过发送HTTP请求检查目标网站上是否存在特定目录,并记录非404状态码的响应结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Python扫描网站的目录代码:

import requests
import time
def getstatus(str,urls):

        url = urls+str
        headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}
        proxies = {'http': None, 'https': None}
        try:
            response = requests.get(url,  headers=headers, proxies=proxies)
            print(url)
            ##print(response.status_code)
            ##print(response.content)
            if response.status_code == 404:
                print(response.status_code)
            else:
                f2 = open('h2bcc-result.txt', 'a')
                f2.write('\n' + str)
                f2.close()
                print(response.status_code)

        except Exception as e:
            time.sleep(5000)
            pass





f = open("h2bcc.txt")
urls = input('请输入你要查的网址:')
f1 = open('h2bcc-result.txt', 'a')
f1.write('\n'+'===='+urls+'====')
f1.close()
result = list()
for line in f.readlines():

    line = line.strip()

    if not len(line) or line.startswith('#'):
        continue
    else:
        getstatus(line, urls)

原文地址:Python扫描网站目录简单测试 | python每日一贴

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值