{"id":3186,"date":"2023-11-05T12:19:03","date_gmt":"2023-11-05T21:19:03","guid":{"rendered":"https:\/\/crm270s.wordpress.com\/?p=3186"},"modified":"2023-11-05T12:19:03","modified_gmt":"2023-11-05T21:19:03","slug":"%ec%84%9c%ec%9a%b8-%ea%b5%ac%ea%b8%80-%eb%a7%b5-phone-extract-original","status":"publish","type":"post","link":"https:\/\/crm270s.mycpamytax.com\/?p=3186","title":{"rendered":"\uc11c\uc6b8 \uad6c\uae00 \ub9f5 Phone Extract &#8211; ORIGINAL"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/perl\n\nuse strict;\nuse warnings;\nuse HTML::TokeParser;\n\n# Input file containing a list of file names\nmy $file_list = 'moving_seoul.txt';\n\n# Output file for saving extracted phone numbers\nmy $output_file = 'moving_seoul_extracted.txt';\n\n# Open the file list for reading\nopen my $file_list_fh, '&lt;', $file_list or die \"Cannot open file list '$file_list': $!\";\n\n# Open the output file for writing\nopen my $output_fh, '&gt;', $output_file or die \"Cannot open output file '$output_file': $!\";\n\n# Iterate through each file listed in the input file\nwhile (&lt;$file_list_fh&gt;) {\n    chomp;  # Remove newline characters\n    my $input_file = $_;\n\n    # Open the current input file for reading\n    open my $input_fh, '&lt;', $input_file or warn \"Cannot open input file '$input_file': $!\";\n\n    # Create an HTML::TokeParser object for the current input file\n    my $parser = HTML::TokeParser-&gt;new($input_fh);\n\n    my $extract = 0;  # Flag to indicate whether to extract content between span and div tags\n\n    # Iterate through the tokens in the current input file\n    while (my $token = $parser-&gt;get_token) {\n        if ($token-&gt;&#091;0] eq 'S') {\n            my $tag = $token-&gt;&#091;1];\n\n            # Check if the tag is \"span\" or \"div\" with class attribute containing \"UsdlK\" or \"W4Efsd\"\n            my $class = $token-&gt;&#091;2]-&gt;{class} || '';\n            if (($tag eq 'span' &amp;&amp; $class =~ \/UsdlK\/) || ($tag eq 'div' &amp;&amp; $class =~ \/W4Efsd\/)) {\n                $extract = 1;  # Set the extract flag to start extracting\n                next;  # Skip the current token\n            }\n        }\n\n        if ($extract &amp;&amp; $token-&gt;&#091;0] eq 'T') {\n            # Extract and print the text content\n            my $content = $token-&gt;&#091;1];\n            print $output_fh \"$content\\n\";\n        }\n\n        if ($extract &amp;&amp; $token-&gt;&#091;0] eq 'E') {\n            my $tag = $token-&gt;&#091;1];\n\n            # Reset the extract flag when the closing span or div tag is encountered\n            if ($tag eq 'span' || $tag eq 'div') {\n                $extract = 0;\n            }\n        }\n    }\n\n    # Close the current input file\n    close $input_fh;\n}\n\n# Close the file list and output file\nclose $file_list_fh;\nclose $output_fh;\n\n# Print a completion message\nprint \"Extraction complete. Extracted content between &lt;span class=\\\"UsdlK\\\"&gt;, &lt;div class=\\\"W4Efsd\\\"&gt;, and their corresponding closing tags is saved in '$output_file'\\n\";\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[26],"tags":[],"class_list":["post-3186","post","type-post","status-publish","format-standard","hentry","category-codes"],"_links":{"self":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3186"}],"version-history":[{"count":0,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3186\/revisions"}],"wp:attachment":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}