24、利用自动化与工具进行信息挖掘及网站防护

利用自动化与工具进行信息挖掘及网站防护

1. 自动化文件搜索与正则表达式的运用

文件搜索相对直接,尤其是在明确所需文件类型的情况下。有时,离线搜索文件是必要的。例如,若要搜索雅虎邮箱地址,使用“@yahoo.com”进行网页搜索效果不佳,群组搜索也存在问题。

为解决此类问题,可使用正则表达式。以下是一个用于搜索文件中特定字符串的 Perl 脚本:

#!/usr/bin/perl
#
# Usage: ./ssearch.pl  FILE_TO_SEARCH  WORDLIST
#
# Locate words in a file, coded by James Foster
#
use strict;
open(SEARCHFILE,$ARGV[0]) || die("Can not open searchfile because $!");
open(WORDFILE,$ARGV[1]) || die("Can not open wordfile because $!");
my @WORDS=<WORDFILE>;
close(WORDFILE);
my $LineCount = 0;
while(<SEARCHFILE>) {
    foreach my $word (@WORDS) {
        chomp($word);
        ++$LineCount;
        if(m/$word/) {
            print "$&\n";
            last;
        }
    }
}
close(SEARCHFILE);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值