For starters this is the code that I have
<?php
include ('parser_class.php');
$source = file_get_html('http://www.billboard.com/search/site/awards?f[0]=ss_bb_type%3Aarticle');
$title = $source->find('h3.title'); //getting song title
?>
<div id="awar">
<?php
if ($title){
$title = array_slice($title, 0, 10);
foreach($title as $titles){
$links = $titles->href;
$string = $titles->innertext;
//$string = (strlen($string) > 75) ? substr($string,0,72).'...' : $string;
?>
<center>
<table style="width: 100%;">
<tr>
<td style="width: 50%; text-align: left; padding-left: 5px;"><span class="song"><?php echo $string ?></span></td><td style="width: 25%; text-align: left; padding-left: 5px;"><a href="http://www.billboard.com<?php echo $links ?>" class="download">Read Article</a></td>
</tr>
</table>
</center>
<hr class="betw" />
<?php
}
}
else{
echo"<p class='song'>No Articles Found</p>";
}
?>
Since the website has no classes on their links I am having to pull my information from something like this
<h3 class="title">
<a href="/articles/columns/country/6784891/lady-antebellum-charles-kelley-steps-out-on-his-own">Lady Antebellum's Charles Kelley Steps Out On His Own In New York City</a>
</h3>
Calling for innertext
I get everything within the h3
What I need is to figure out how to get the href
and the anchor text
separately from within the h3
Is there a way to get the href
from the innertext
and then the innertext
of the href
?
I wish that this site had a class on their links as that would of course make this tons easier. I have used these functions with no issues because of the websites actually using classes on their links, but it looks like billboard has decided to make things harder for me!
A point in the right direction would be greatly appreciated.
NOTE: My parser_class.php
is the one that is located here