{"id":3597,"date":"2024-02-10T19:50:24","date_gmt":"2024-02-11T04:50:24","guid":{"rendered":"https:\/\/crm270s.abramjmeister.com\/?p=3597"},"modified":"2024-02-10T19:50:24","modified_gmt":"2024-02-11T04:50:24","slug":"bizname-pl","status":"publish","type":"post","link":"https:\/\/crm270s.mycpamytax.com\/?p=3597","title":{"rendered":"bizname.pl"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">each downloaded html bizname extraction perl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/perl\nuse strict;\nuse warnings;\nuse HTML::TokeParser;\n\n# Define the filename containing the list of HTML files\nmy $filename = \"file_names.txt\";\n\n# Open the file containing the list of HTML files\nopen my $file_list_fh, '&lt;', $filename or die \"Cannot open file $filename: $!\";\n\n# Open the output file for writing\nopen my $output_fh, '>', \"bizname.txt\" or die \"Cannot open file bizname.txt for writing: $!\";\n\n# Loop through each line of the file\nwhile (my $html_file = &lt;$file_list_fh>) {\n    chomp $html_file; # Remove newline character\n    next if $html_file =~ \/^\\s*$\/; # Skip empty lines\n\n    # Remove leading and trailing whitespace from the filename\n    $html_file =~ s\/^\\s+|\\s+$\/\/g;\n\n    # Open and read the HTML file\n    open my $html_fh, '&lt;', $html_file or die \"Cannot open file $html_file: $\/\";\n    my $html_content = do { local $\/; &lt;$html_fh> };\n    close $html_fh;\n\n    # Create a new HTML::TokeParser object\n    my $parser = HTML::TokeParser->new(\\$html_content);\n\n    # Flag to indicate whether we are inside the specified div tag\n    my $inside_div = 0;\n\n    my $extracted_content = \"\"; # Initialize variable to store extracted content\n\n    # Loop through the tokens\n    while (my $token = $parser->get_token) {\n        if ($token->&#91;0] eq 'S' &amp;&amp; $token->&#91;1] eq 'div' &amp;&amp; defined $token->&#91;2]{'style'} &amp;&amp; $token->&#91;2]{'style'} =~ \/margin-top:5px;text-align: left;font-weight:700;\/) {\n            # Start of the specified div tag\n            $inside_div = 1;\n        } elsif ($inside_div) {\n            if ($token->&#91;0] eq 'T') {\n                # Text token inside the div\n                $extracted_content .= $token->&#91;1]; # Append content to extracted content\n            } elsif ($token->&#91;0] eq 'E' &amp;&amp; $token->&#91;1] eq 'br') {\n                # End of the div when encountering a br tag\n                $inside_div = 0;\n                last; # Exit the loop\n            }\n        }\n    }\n\n    # Print the extracted content followed by the filename, separated by a semicolon\n    print $output_fh \"$extracted_content; $html_file\\n\";\n\n    print \"Extracted content from $html_file\\n\";\n}\n\n# Close the files\nclose $file_list_fh;\nclose $output_fh;\n\nprint \"All extracted content saved to bizname.txt\\n\";\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>each downloaded html bizname extraction perl:<\/p>\n","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-3597","post","type-post","status-publish","format-standard","hentry","category-codes"],"_links":{"self":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3597","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=3597"}],"version-history":[{"count":0,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=\/wp\/v2\/posts\/3597\/revisions"}],"wp:attachment":[{"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crm270s.mycpamytax.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}