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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.