59 |
my $contents = $response->content(); |
my $contents = $response->content(); |
60 |
|
|
61 |
open( CONTENTS, ">$localpath.contents" ) || die( "Could not open contents file $localpath.contents\n" ); |
open( CONTENTS, ">$localpath.contents" ) || die( "Could not open contents file $localpath.contents\n" ); |
62 |
|
# if you don't want content to be indexed, include it in |
63 |
|
# <noindex> foobar </noindex> tags or surround it with comments |
64 |
|
# <!-- noindex --> foobar <!-- /noindex --> |
65 |
$contents =~ s,<noindex>.+?</noindex>,,isg; |
$contents =~ s,<noindex>.+?</noindex>,,isg; |
66 |
$contents =~ s,<!--\s*noindex\s*-->.+?<!--\s*/noindex\s*-->,,isg; |
$contents =~ s,<!--\s*noindex\s*-->.+?<!--\s*/noindex\s*-->,,isg; |
67 |
|
# this will remove all script from indexing content |
68 |
$contents =~ s,<script>.+?</script>,,isg; |
$contents =~ s,<script>.+?</script>,,isg; |
69 |
|
# remap Windows charset to ISO-8859-2 |
70 |
$contents =~ tr/šðžèæŠÐŽÈÆ/¹ð¾èæ©Ð®ÈÆ/; # 1250 -> iso8859-2 |
$contents =~ tr/šðžèæŠÐŽÈÆ/¹ð¾èæ©Ð®ÈÆ/; # 1250 -> iso8859-2 |
71 |
|
# this will fix badly formatted html in form: |
72 |
|
# <head><title>some text</title |
73 |
|
# ></head> |
74 |
|
# which will confuse indexer (or libxml2?) |
75 |
|
$contents =~ s/[\n\r]^(>)/$1\n/msg; |
76 |
|
# remove comments between <html> and <head> texi2html inserts them |
77 |
|
# there and swish can't find document title then (libxml or swish bug?) |
78 |
|
while ($contents =~ s/(<html>.*)<!--.*?-->(.*<head>)/$1$2/msi) { }; |
79 |
print CONTENTS $contents; |
print CONTENTS $contents; |
80 |
close( CONTENTS ); |
close( CONTENTS ); |
81 |
|
|