Xmodding Posted October 5, 2013 Share Posted October 5, 2013 (edited) Hi can someone help me out as i'm new to php. I have a grabber built in to my script that gets info from other sites for example. This part is from the site that my grabber gets the info from. <div class="txt-block"> <h4 class="inline">Runtime:</h4> <time itemprop="duration" datetime="PT103M">103 min</time> </div> And this is how my grabber gets this info from the site. $times = $dom->getElementsByTagName('time'); for($i=0; $i<$times->length; $i++){ $itemprop = $times->item($i)->getAttribute("itemprop"); if ($itemprop == "duration"){ if ($times->item($i)->textContent!='-'){ $res['duration'] = $times->item($i)->textContent; } } } Now what i'm stuck on is what would the code be to get the date published from the site. <span class="nobr"> <a href="/title/tt0099785/releaseinfo?ref_=tt_ov_inf " title="See all release dates"> 16 November 1990 <meta itemprop="datePublished" content="1990-11-16"> (USA) </a> </span> Would it be something like this. $meta = $dom->getElementsByTagName('meta'); for($i=0; $i<$meta->length; $i++){ $itemprop = $meta->item($i)->getAttribute("itemprop"); if ($itemprop == "datePublished"){ if ($meta->item($i)->textContent!='-'){ $res['datePublished'] = $meta->item($i)->textContent; } } } Could someone please help as i don't have a clue about writing php. Edited October 5, 2013 by Xmodding Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 6, 2013 Share Posted October 6, 2013 Not, sure but you need to get the date from the content attribute so maybe $meta = $dom->getElementsByTagName('meta'); for($i=0; $i<$meta->length; $i++){ $itemprop = $meta->item($i)->getAttribute("itemprop"); if ($itemprop == "datePublished"){ $res['datePublished'] = $meta->item($i)->getAttribute("content"); } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.