서울 구글 맵 extracting phone, adding file name extraction is from

#!/usr/bin/perl

use strict;
use warnings;
use HTML::TokeParser;

# Output file for saving extracted content
my $output_file = 'moving_seoul_extracted.txt';

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

# Iterate through each file from 1.mhtml to 25.mhtml
for my $file_number (1..25) {
    my $input_file = "${file_number}.mhtml";

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

    # Create an HTML::TokeParser object for the current input file
    my $parser = HTML::TokeParser->new($input_fh);

    my $extract = 0;  # Flag to indicate whether to extract content between span and div tags

    # Iterate through the tokens in the current input file
    while (my $token = $parser->get_token) {
        if ($token->[0] eq 'S') {
            my $tag = $token->[1];

            # Check if the tag is "span" or "div" with class attribute containing "UsdlK" or "W4Efsd"
            my $class = $token->[2]->{class} || '';
            if (($tag eq 'span' && $class =~ /UsdlK/) || ($tag eq 'div' && $class =~ /W4Efsd/)) {
                $extract = 1;  # Set the extract flag to start extracting
                next;  # Skip the current token
            }
        }

        if ($extract && $token->[0] eq 'T') {
            # Extract and write the text content along with the file name to the output file
            my $content = $token->[1];
            print $output_fh "$input_file: $content\n";
        }

        if ($extract && $token->[0] eq 'E') {
            my $tag = $token->[1];

            # Reset the extract flag when the closing span or div tag is encountered
            if ($tag eq 'span' || $tag eq 'div') {
                $extract = 0;
            }
        }
    }

    # Close the current input file
    close $input_fh;
}

# Close the output file
close $output_fh;

# Print a completion message
print "Extraction complete. Extracted content with file names is saved in '$output_file'\n";

phone extract PYTHON code – FINAL

import re
import PyPDF2
import importlib
import subprocess
import csv
import os

def install_missing_package(package):
    try:
        importlib.import_module(package)
    except ImportError:
        subprocess.check_call(['pip', 'install', package])

def extract_phone_numbers_from_pdf(file_path):
    phone_numbers = []
    
    # Open the PDF file
    with open(file_path, 'rb') as file:
        # Create a PDF reader object
        reader = PyPDF2.PdfReader(file)
        
        # Iterate over each page in the PDF
        for page in reader.pages:
            # Extract the text from the page
            text = page.extract_text()
            
            # Use regular expressions to find phone numbers
            # This pattern matches US phone numbers in various formats
            pattern = r'(\+\d{1,2}\s?)?(\()?(\d{3})(?(2)\))[-.\s]?(\d{3})[-.\s]?(\d{4})'
            matches = re.findall(pattern, text)
            
            # Format the phone numbers as (###) ###-####
            formatted_numbers = ['({}) {}-{}'.format(*match[2:]) for match in matches]
            
            # Add the matched phone numbers to the list
            phone_numbers.extend(formatted_numbers)
    
    return phone_numbers

# Check if PyPDF2 is installed, and install it if necessary
install_missing_package('PyPDF2')

# Read the text file with a list of PDF file names
pdf_list_file = 'pdf_files.txt'
with open(pdf_list_file, 'r') as file:
    pdf_files = file.read().splitlines()

# Extract phone numbers from each PDF and store them in a list
phone_number_list = []
for pdf_file in pdf_files:
    phone_numbers = extract_phone_numbers_from_pdf(pdf_file)
    phone_number_list.extend([(pdf_file, number) for number in phone_numbers])

# Write the extracted phone numbers to a CSV file
csv_file = 'phone_extracts.csv'
with open(csv_file, 'w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['PDF Name', 'Phone Number'])
    writer.writerows(phone_number_list)

# Print the success message
print(f"Phone numbers extracted from {len(pdf_files)} PDF files and saved to {csv_file}.")

phone extract PYTHON code

import re
import PyPDF2
import importlib
import subprocess

def install_missing_package(package):
    try:
        importlib.import_module(package)
    except ImportError:
        subprocess.check_call(['pip', 'install', package])

def extract_phone_numbers_from_pdf(file_path):
    phone_numbers = []
    
    # Open the PDF file
    with open(file_path, 'rb') as file:
        # Create a PDF reader object
        reader = PyPDF2.PdfReader(file)
        
        # Iterate over each page in the PDF
        for page in reader.pages:
            # Extract the text from the page
            text = page.extract_text()
            
            # Use regular expressions to find phone numbers
            # This pattern matches US phone numbers in various formats
            pattern = r'(\+\d{1,2}\s?)?(\()?(\d{3})(?(2)\))[-.\s]?(\d{3})[-.\s]?(\d{4})'
            matches = re.findall(pattern, text)
            
            # Format the phone numbers as (###) ###-####
            formatted_numbers = ['({}) {}-{}'.format(*match[2:]) for match in matches]
            
            # Add the matched phone numbers to the list
            phone_numbers.extend(formatted_numbers)
    
    return phone_numbers

# Check if PyPDF2 is installed, and install it if necessary
install_missing_package('PyPDF2')

# Specify the path to your PDF file
pdf_file_path = 'sample.pdf'

# Extract phone numbers from the PDF file
phone_numbers = extract_phone_numbers_from_pdf(pdf_file_path)

# Print the extracted phone numbers
for number in phone_numbers:
    print(number)

770-622-9600

한국일보 – Atlanta

2023년도판 1월말에 준비되며 $10 지불하면 우송해 준단다 (1/2/2023)

Fall 2023 ~ ..

일년 푹 쉬면서 $1.6万 더 비축하고 확고한 장래 계획을..

  • Able-Now ~$45,000 2023年말
  • CsamiGroup.com 541511 Divi
  • – 연변 App 全 美州 업소록 ready
  • BookkeeperJohn.com 541211
  • – QBO EA
  • JinuAcademy.com 611691 -QBO, -Math
  • – Cengage Unlimited
  • – LifterLMS
  • LATimes 月$2.99 through VPN & Speechelo
  • 561510 EBS / Economist / National Geo.
  • GRE General / Math Subject
  • M.Ed Credential, UAF Admission
  • 毎週 1 ~ 2번 Sauna / Swim, Grocery Shuttle

646-775-7218

학원. 이영민씨. 학원은 문 닫았고 다른 비지니스 하는 듯. 현재 해외에 있어서 나중에 다시 연락한단다 (8/11/2022).

현재 직장 생활 한단다 (4/2/2024).

516-365-1601

학원. pes1600usa@gmail.com Joanne 메니저 talked. Director에게 물어 본단다. 웹 사이트 있으나 업데이트 필요. 관련 정보 이멜로 보내란다 (8/3/2022).

이멜 sent on 8/3/2022.

201-944-9320

학원. 웹 사이트 있으나 update이 안 된 상태. 아직은 도움 필요 없고 필요할 때 연락 한다고 내 전화 번호 메모했음 (8/2/2022).

http://emiacademy.com/ – seems this is their current web address.

원장 여인과 통화. 월 $45이라고 얘기했음. approachable. 의논 좀 하고 연락하겠다고 내 전화 번호 받았음 (4/2/2024).

347-633-1550

잡지사. Jenny 윤씨. “NJ Magazine” 학원 안 하고 hard copy magazine 발행하고 있는데 잡지를 온라인으로 어떻게 도움 볼 수 있냐고 물음. PDF로 만들어 웹에 올리고 구독료 받을 수 있다고 했음. 현재 다른 용무로 바쁘고 오후에 연락 준단다 (8/2/2022).