chapangzhan.com爬C段域名脚本

import requests,re
import urllib3

def title():
    print('+------------------------------------------')
    print('+  \033[36mDescribe: cmd下直接运行iippcc.py即可          \033[0m')
    print('+  \033[36m第一个输出内容,例 >>> 111.11.22.0/24                                \033[0m')
    print('+  \033[36m第二个输出内容,例 >>> 要查询域名的相同字符,比如www.baidu.com中的baidu      \033[0m')
    print('+  \033[36mC段地址保存在同级目录下的ipC.txt文件中                                \033[0m')
    print('+  \033[36m域名链接保存在link.txt文件中     \033[0m')
    print('+------------------------------------------')


def ipC(ip):
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Geocko/20100101 Firefox/60.0'}
    url = 'https://chapangzhan.com/' + ip
    resp = requests.get(url, headers=headers, verify=False)
    ipdate = re.findall('<a href="(.+?)"', resp.text)
    for ip1 in ipdate:
        if 'https://ipchaxun.com/' in ip1:
            new_ip = ip1.replace("https://ipchaxun.com/", "").rstrip("/")
            print(new_ip)
            with open(r'ipC.txt', 'a+') as f:
                f.write(new_ip + '\n')
                f.close()


def link(keywords):
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Geocko/20100101 Firefox/60.0'}
    for ip in open('ipC.txt'):
        ip = ip.replace('\n', '')
        url = 'https://ipchaxun.com/' + ip
        resp = requests.get(url, headers=headers, verify=False)
        links = re.findall('<a href="(.+?)"', resp.text)
        for link in links:
            if keywords in link:
                link = link.strip("/")
                new_link = 'http://' + link
                print(new_link)
                # with open(r'link.txt', 'a+') as f:
                #     f.write(new_link + '\n')
                #     f.close()




if __name__ == '__main__':
    urllib3.disable_warnings()
    title()
    ip = input('+  \033[35m请输入要查询的C段$:\033[0m')
    ipC(ip)
    keywords = input('+  \033[35m请输入域名中的关键字$:\033[0m')
    link(keywords)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值