Reputation: 199
Currently I am scraping a website which has this content displayed.
<h2 class="entry-title">
<a href="http://www.example.com">Song Artist - Song Name</a>
</h2>
Now if I use the code provided below it will pull what's shown above but I want to get just the portion that is as the Song Artist - Song Name without the <a href=""></a>
or <h2></h2>
tags.
$html = file_get_html("http://www.example.com");
foreach ($html->find('h2[class="entry-title"]') as $data)
{
echo $data;
};
Upvotes: 1
Views: 68
Reputation: 1
@krishna Gupta
echo $data->innertext;
this will result with something like
<a href="http://www.example.com">Song Artist - Song Name</a>
@Slacks
Just use
echo $data->plaintext;
Upvotes: 0
Reputation: 685
foreach ($html->find('h2[class="entry-title"] a') as $data)
{
echo $data->innertext;
};
Upvotes: 1
Reputation: 3644
After a bit of digging through their pretty ancient docs:
echo $data->children(0)->innertext
Should work.
Upvotes: 1