Jump to content


Grabbing Info From Site's HTML DOM Parser

php dom parser html

  • Please log in to reply
1 reply to this topic

#1 Xmodding



  • New Members
  • Pip
  • 1 posts

Posted 05 October 2013 - 07:31 PM

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>

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">

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 by Xmodding, 05 October 2013 - 07:43 PM.

#2 Ch0cu3r


    Advanced Member

  • Moderators
  • 3,240 posts

Posted 06 October 2013 - 09:03 AM

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");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users