Get element using PHP or Javascript -
i'm trying value of element page http://mhs.mamkschools.org on right sidebar shows day ("day 4"), i've tried using domdocument, regex , few other options. wondering if of able me out this. thanks.
i'm assuming have html.
<?php $htmlstring = <<<eof <div class="upcomingevent"> <div class="upcomingeventinner"> <div class="uecontent"> <div id="ctl00_lm_wp411648411_ctl00_template_upcomingevents_ctrl0_events_ctrl0_ctl00_titleplaceholder" class="uetitle"> <span>day 4</span></div> <div class="clear-both"></div> </div> </div> </div> </div> <div class="upcomingeventday"> <div class="uedate"><span class="uedatebullet color-pc"></span>tuesday, september 23</div> <div class="upcomingevent"> <div class="upcomingeventinner"> eof; $doc = new domdocument(); $doc->stricterrorchecking = false; @$doc->loadhtml( $htmlstring ); $el = $doc->getelementbyid( 'ctl00_lm_wp411648411_ctl00_template_upcomingevents_ctrl0_events_ctrl0_ctl00_titleplaceholder' ); var_dump(trim( $el->nodevalue )); ?>
for regex:
preg_match_( '~<span>day [0-9]+<\/span>~i', $html, $res ); print_r( $res );
Comments
Post a Comment