웹 (연변 – 한국) codes

#!/usr/bin/perl

use strict;
use warnings;

# Input file
my $input_file = 'business_type_original.txt';

# Output file
my $output_file = 'business_type_replaced.txt';

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

# Open the output file for writing
open my $output_fh, '>', $output_file or die "Cannot open output file '$output_file': $!";

# Process each line of the input file
while (my $line = <$input_fh>) {
    # Replace "이삿짐" with "치과" in the line
    $line =~ s/이삿짐/회계 사무실/g;

    # Write the modified line to the output file
    print $output_fh $line;
}

# Close the input and output files
close $input_fh;
close $output_fh;

print "Replacement complete. Results saved in '$output_file'\n";
select '"' || field1 || '",' from business_type_replaced order by field1 desc
<!DOCTYPE html>
<html>
<head>
    <title>Open Search Words in Reverse Order</title>
</head>
<body>
    <script>
        var searchWords = [
"이삿짐 중랑구 서울특별시",
"이삿짐 중구 서울특별시",
"이삿짐 종로구 서울특별시",
"이삿짐 은평구 서울특별시",
"이삿짐 용산구 서울특별시",
"이삿짐 영등포구 서울특별시",
"이삿짐 양천구 서울특별시",
"이삿짐 송파구 서울특별시",
"이삿짐 성북구 서울특별시",
"이삿짐 성동구 서울특별시",
"이삿짐 서초구 서울특별시",
"이삿짐 서대문구 서울특별시",
"이삿짐 마포구 서울특별시",
"이삿짐 동작구 서울특별시",
"이삿짐 동대문구 서울특별시",
"이삿짐 도봉구 서울특별시",
"이삿짐 노원구 서울특별시",
"이삿짐 금천구 서울특별시",
"이삿짐 구로구 서울특별시",
"이삿짐 광진구 서울특별시",
"이삿짐 관악구 서울특별시",
"이삿짐 강서구 서울특별시",
"이삿짐 강북구 서울특별시",
"이삿짐 강동구 서울특별시",
"이삿짐 강남구 서울특별시"
        ];

        for (var i = 0; i < Math.min(25, searchWords.length); i++) {
            window.open("https://www.google.com/search?q=" + encodeURIComponent(searchWords[i]), "_blank");
        }
    </script>
</body>
</html>



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\t$line";  # Use a tab character as the delimiter
        }

        # 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\t$plus82_content";  # Use a tab character as the delimiter
        }
    }

    # 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";
use strict;
use warnings;

# Initialize variables to store extracted URLs
my @google_maps_urls;

# 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': $!";

    my $previous_line = '';
    my $current_line = '';
    my $extracting = 0;

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

        # Check if the current line contains "+82"
        if ($current_line =~ /\+82/) {
            # Check if the next line contains "Website"
            if ($line =~ /Website/) {
                $extracting = 1;
                push @google_maps_urls, "$input_file, $current_line";
            }
        }

        # Continue extracting 3 more lines if we're in an extraction state
        if ($extracting) {
            push @google_maps_urls, "$input_file, $line";
            if (@google_maps_urls % 4 == 0) {
                $extracting = 0;
            }
        }

        # Store the current line for the next iteration
        $previous_line = $current_line;
        $current_line = $line;
    }

    # Close the current input file
    close $input_fh;
}

# Save the extracted URLs to a file
my $output_file = 'firefox_website_02.txt';
open my $output_fh, '>', $output_file or die "Cannot open output file '$output_file': $!";

foreach my $url (@google_maps_urls) {
    print $output_fh "$url\n";
}

# Close the output file
close $output_fh;

print "Extraction complete. Extracted 4 lines (including +82 and Website) are saved in '$output_file'\n";

82.txt

SELECT
    field1, field2,
    CASE
        WHEN INSTR(field2, '+82') > 0 THEN
            SUBSTR(field2, INSTR(field2, '+82'))
        ELSE
            field2
    END AS extracted_value
FROM firefox_website_02;

http.txt

SELECT
    extracted_value, field1, field2,
    CASE
        WHEN field2 LIKE '<%' AND field2 LIKE '%>' THEN
            SUBSTR(field2, INSTR(field2, '<') + 1, INSTR(field2, '>') - INSTR(field2, '<') - 1)
        WHEN field2 LIKE '<%' THEN
            'Starts with <, but missing >'
        ELSE
            'Does not start with <'
    END AS extracted_value
FROM firefox_website_02_PHONE;