0

I want to get the data from the tag.

<div class="module question_card_categories  jsparams js-question_card_categories">

for this i create the code like this

<?php

include('simple_html_dom.php');
$html = file_get_html("http://$a");
$tag = $html->find('div[class=module question_card_categories  jsparams js-question_card_categories]', 0);echo $tag;
 ?>

but sir nothing happen . Plz help me on this. i try multiple time but result is zero.nothing is displaying.

2
  • $a was the source file ? Commented Jul 5, 2015 at 10:24
  • yes it is sorce file Commented Jul 5, 2015 at 10:24

2 Answers 2

1

You can get the content by

$Content = file_get_contents($url);

Then explode it by

$Head = explode( '<div class="module question_card_categories  jsparams js-question_card_categories">' , $Content );

And explode it till the </div> by

$Body = explode("</div>" , $Head[1] );

So, If this is your html file

<div class="module question_card_categories  jsparams js-question_card_categories">Hellow Here i am </div>>

You can get the content by

<?php
$url = 'Yourfile.html';
$Content = file_get_contents($url);
$Head = explode( '<div class="module question_card_categories  jsparams js-question_card_categories">' , $Content );
$Body = explode("</div>" , $Head[1] );
echo $Body[0];

Result :

Hellow Here i am

Here is the Eval

Update :

As the user want to get the categories of this url

<?php
$url = 'http://www.answers.com/Q/What_is_the_verb_of_receipt';
$Content = file_get_contents($url);
$Head = explode( '<ul class="categoryMenu categories">' , $Content );
$Body = explode("</ul>" , $Head[1] );
echo $Body[0];
Sign up to request clarification or add additional context in comments.

4 Comments

Are you sure you given the correct path, Bcoz it works great in my local machine :)
answers.com/Q/What_is_the_verb_of_receipt i want to get the category from this url
You want this one ? English Language Grammar Languages and Cultures Literature & Language Parts of Speech ?
I have updated the answer, which gets the categories from the url you given ;)
0

You could get the content of the div as:

$tag = $html->find('div[class=module question_card_categories  jsparams js-question_card_categories]', 0);

echo  htmlspecialchars($tag); //shows you the tag and content

echo  $tag->innertext; //shows the text within the div

See the manual

1 Comment

What is the of value $a ? Please edit your post and show the current code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.