Hi Monks, I inherited some code to extract specific data from html. The html has changed and the code doesn't parse and push the text I need. I was up till 3AM last night trying everything. As far as the CSS syntax there is a find for an anchor in the HTML and then a find for several classes to pull text, about 12 per page. It's such a large script I'm having problems making a tear out to test and need to run this large script every time to test which is part of the problem as well. Please find the part of the code that is broken below and the html. Thank you very much in advance for any insight and guidance you can provide
This is what I have from the script:
print "curent working directory is $ENV{PWD}, \n"; chdir ( "$config->{'data_path'}/" ); @files7 = grep { -f } glob("*.html"); foreach (@files7){ print "Newparse2 == Parsing file: $_ \n"; $$temp_content = path($_)->slurp_utf8; $$output_csv .= qq|"$_"\n\n|; $$name4url .= qq|"$_"\n\n|; my $dom1 = Mojo::DOM->new( $$temp_content ); my $r1 = $dom1->find('[class="JMWMJ"]'); #my $r1 = $dom1->find('.JMWMJ'); #my $r1 = $dom1->find('div.JMWMJ'); print "1.1YYY - Config WebSite is $config->{'website'}\n"; foreach my $block ( @{$r1}){ $block =~ s#\s-\s|\s\|\s#%%#g; my $dom2 = my $r2 = my $r3 = my $r4 = my $r5 = undef; m +y $res = {}; my @d = (); $dom2 = Mojo::DOM->new( $block ); my $r101; my @columns; my @columns101; #####added stuff here 01142012 print "1.2YYY - Config WebSite is $config->{'website'}\n"; ##$r2 = $dom2->find('CVA68e.qXLe6d.fuLhoc.ZWRArf', 'qXLe6d FrI +lee') -> map( sub{ $_->text } ); ## $r2 = $dom2->at('h3.LC20lb.MBeuO.DKV0Md','h3.BNeawe.vvjw +Jb.AP7Wnd','h3.CVA68e.qXLe6d', ## ,'h3.CVA68e.qXLe6d.fuLhoc.ZWRArf','h3.qXLe6d.FrIlee', ' +h3.toI8Rb.OSrXXb.usbThf') $r2 = $dom2->find('h3') ->each(sub { push @columns, join '|', map { $_->all_text } $_->find('span' +)->each; });
This is the html that the code is supossed to parse
<div class="JMWMJ"><div class="toI8Rb OSrXXb usbThf">Sam Namett, MD - +Physician - Interventional Orthopedics ...Exosomes are nanovesicles ( +30-200 nm) found in extracellular space of various cell types, and in + biofluids; having diverse functions including intracellular ...</div +></div><div class="Xxy7Vb"><div class="BtwlAd"><g-img style="width:16 +px;height:16px"><img id="dimg_8" src="data:image/gif;base64,R0lGODlhA +QABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
I'm trying to extract the text from the class, the info like this from the page and there are multiple blocks on each html page
Sam Namett, MD - Physician - Interventional Orthopedics ...Exosomes are nanovesicles (30-200 nm) found in extracellular space of various cell types, and in biofluids; having diverse functions including intracellular ...
Thanks again for any insight you can provide.
In reply to perl Mojo DOM CSS syntax issues by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |