-
-
Save hesco/c2fca7f23eaca266993d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'phones' => bless( [ | |
bless( do{\(my $o = bless( { | |
'xml' => undef, | |
'tree' => [ | |
'tag', | |
'div', | |
{ | |
'itemprop' => 'telephone', | |
'class' => 'mn-member-phone1' | |
}, | |
undef, | |
[ | |
'text', | |
'(912) 634-7377', | |
${$VAR1->{'phones'}[0]}->{'tree'} | |
] | |
] | |
}, 'Mojo::DOM::HTML' ))}, 'Mojo::DOM' ), | |
bless( do{\(my $o = bless( { | |
'xml' => undef, | |
'tree' => [ | |
'tag', | |
'div', | |
{ | |
'itemprop' => 'telephone', | |
'class' => 'mn-member-phone2' | |
}, | |
undef, | |
[ | |
'text', | |
'(800) 569-1955', | |
${$VAR1->{'phones'}[1]}->{'tree'} | |
] | |
] | |
}, 'Mojo::DOM::HTML' ))}, 'Mojo::DOM' ) | |
], 'Mojo::Collection' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This: | |
sub parse_phones { | |
my $self = shift; | |
my $dom = shift; | |
my $phones = $dom->at( '#mn-member-general > div > div.mn-member-basicinfo' )->attr( 'itemprop' => 'telephone' ); | |
return $phones; | |
} | |
hoping to see: | |
'phones' => [ '912-555-1212', '800-555-1212' ], | |
got me this close: | |
'phones' => bless( do{\(my $o = bless( { | |
'tree' => [ | |
'tag', | |
'div', | |
{ | |
'itemscope' => 'itemscope', | |
'class' => 'mn-member-basicinfo', | |
'itemtype' => 'http://schema.org/PostalAddress', | |
'itemprop' => 'telephone' | |
}, | |
undef, | |
[ | |
'text', | |
' | |
', | |
${$VAR1->{'phones'}}->{'tree'} | |
], | |
[ | |
'tag', | |
'div', | |
{ | |
'itemprop' => 'streetAddress', | |
'class' => 'mn-member-address' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}, | |
[ | |
'text', | |
'103 Main Street', | |
${$VAR1->{'phones'}}->{'tree'}->[5] | |
] | |
], | |
[ | |
'text', | |
' | |
', | |
${$VAR1->{'phones'}}->{'tree'} | |
], | |
[ | |
'tag', | |
'div', | |
{ | |
'class' => 'mn-member-cistpost' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}, | |
[ | |
'tag', | |
'span', | |
{ | |
'itemprop' => 'addressLocality' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}->[7], | |
[ | |
'text', | |
'St. Simons Island', | |
${$VAR1->{'phones'}}->{'tree'}->[7]->[4] | |
] | |
], | |
along with other cruft . . . | |
[ | |
'tag', | |
'div', | |
{ | |
'itemprop' => 'telephone', | |
'class' => 'mn-member-phone1' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}, | |
[ | |
'text', | |
'(912) 555-1212', | |
${$VAR1->{'phones'}}->{'tree'}->[9] | |
] | |
], | |
[ | |
'tag', | |
'div', | |
{ | |
'class' => 'mn-member-phone2', | |
'itemprop' => 'telephone' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}, | |
[ | |
'text', | |
'(800) 555-1212', | |
${$VAR1->{'phones'}}->{'tree'}->[11] | |
] | |
], | |
[ | |
'text', | |
' | |
', | |
${$VAR1->{'phones'}}->{'tree'} | |
], | |
[ | |
'tag', | |
'div', | |
{ | |
'itemprop' => 'faxNumber', | |
'class' => 'mn-member-fax' | |
}, | |
${$VAR1->{'phones'}}->{'tree'}, | |
[ | |
'text', | |
'(912) 555-1234 (fax)', | |
${$VAR1->{'phones'}}->{'tree'}->[13] | |
] | |
], | |
[ | |
'text', | |
' | |
', | |
${$VAR1->{'phones'}}->{'tree'} | |
] | |
], | |
'xml' => undef | |
}, 'Mojo::DOM::HTML' ))}, 'Mojo::DOM' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="mn-member-general" class="mn-section"> | |
<div class="mn-section-content"> | |
<div id="mn-member-name-nologo">Cal Duke Publishing, Inc.</div> | |
<div class="mn-memberinfo-block-actions"> | |
<ul> | |
<li id="mn-memberinfo-block-website"><a itemprop="url" href="http://www.caldukepublishing.com/" class="mn-print-url" onclick="MNI.Hit.MemberWebsite(2076)" title="Visit the website of Cal Duke Publishing, Inc." target="_blank">Visit Website</a></li> | |
</ul> | |
</div> | |
<div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress" class="mn-member-basicinfo"> | |
<div itemprop="streetAddress" class="mn-member-address">103 Thompson Cove</div> | |
<div class="mn-member-cistpost"><span itemprop="addressLocality">St. Simons Island</span>, <span itemprop="addressRegion">GA </span><span itemprop="postalCode">31522</span></div> | |
<div itemprop="telephone" class="mn-member-phone1">(912) 634-7377</div> | |
<div itemprop="telephone" class="mn-member-phone2">(800) 569-1955</div> | |
<div itemprop="faxNumber" class="mn-member-fax">(912) 638-0515 (fax)</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$dom->find('div[itemprop="telephone"]')->each(sub{say shift->text});
Can you try this?
or
my @Phones = $dom->find('div[itemprop="telephone"]')->map('text')->each;