利用自动化与工具进行信息挖掘及网站防护
1. 自动化文件搜索与正则表达式的运用
文件搜索相对直接,特别是当你明确所需文件类型时。不过,有时离线搜索文件是必要的。例如,若要搜索雅虎邮箱地址,简单的网络搜索 “@yahoo.com” 邮箱并不高效,群组搜索也存在问题。
比如,一次搜索找到了一个邮箱地址 “jg65_83@yahoo.com”,但也匹配到了 “store.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
超级会员免费看
订阅专栏 解锁全文

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



