firefox_02.pl

use strict;
use warnings;

# Initialize an array to store extracted content
my @extracted_content;

# Process each HTML file (1.html to 25.html)
for my $file_number (1..25) {
    my $input_file = "${file_number}.html";

    # Open the current input file for reading
    open my $input_fh, '<', $input_file or warn "Cannot open input file '$input_file': $!";

    # Read each line and look for URLs and +82 content
    while (my $line = <$input_fh>) {
        chomp $line;

        # Extract URLs matching /https:\/\/www\.google\.com\/maps\/place/
        if ($line =~ /https:\/\/www.google.com\/maps\/place/) {
            # Remove leading '<' and trailing '>'
            $line =~ s/^<(.+)>$/$1/;
            push @extracted_content, "$input_file,$line";
        }

        # Extract content starting with +82 and going to the end of the line
        if ($line =~ /\+82(.+)/) {
            my $plus82_content = "+82$1";  # Include +82 in the extracted content
            push @extracted_content, "$input_file,$plus82_content";
        }
    }

    # Close the current input file
    close $input_fh;
}

# Save the extracted content to a file
my $output_file = 'firefox_02.txt';
open my $output_fh, '>', $output_file or die "Cannot open output file '$output_file': $!";
foreach my $entry (@extracted_content) {
    print $output_fh "$entry\n";
}
close $output_fh;

print "Extraction complete. Extracted content is saved in '$output_file'\n";

Leave a Reply

Your email address will not be published. Required fields are marked *