Reputation: 115
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.
Upvotes: 0
Views: 33
Reputation: 11310
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
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];
Upvotes: 1
Reputation: 2442
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
Upvotes: 0