利用自动化与工具进行信息挖掘及网站防护
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);
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



