Internet Explorerの履歴情報取得


 Win32::OLEを使うためWindowsが対象です。
use strict;
use Win32::OLE;

my $wshell = Win32::OLE->new('Shell.Application') or die "OLE Error.\n";
my $ie_history_folder = $wshell->Namespace(0x22);

my $item_list = get_item_list($ie_history_folder);
foreach my $item (@$item_list) {
	printf "url  : %s\n", $item->{url};
	printf "title: %s\n", $item->{title};
	printf "date : %s\n", $item->{date};
	print "\n";
}

sub get_item_list{
	my $folder = shift;

	my $item_list = [];
	my $items = $folder->items;
	for(my $i = 0; $i < $items->count; $i++){
		my $item = $items->item($i);
		if($item->IsFolder){
			my $list = get_item_list($item->GetFolder);
			push @$item_list, @$list;
		} else {
			my $url = $folder->GetDetailsOf($item, 0);
			my $title = $folder->GetDetailsOf($item, 1);
			my $date = $folder->GetDetailsOf($item, 2);
			push @$item_list, {
				url => $url,
				title => $title,
				date => $date,
			};
		}
	}
	return $item_list;
}

関連項目

なし