OK, I have an HTML DOM Parser. It works... sorta. It's trying to get the text from a div witch has a class.
See the main file
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js">
</script>
<style>
#txt_out {
border: 2px solid #C2C2C2;
color: #2E2E2E;
background: #EDEDED;
width: 97%;
padding: 5px;
font-size: 12px;
font-family: monospace;
outline: none;
height: 800px;
margin: 10px 0;
}
</style>
<title>Get Ranks</title>
<script type="text/javascript" >
$(document).on("click", ".go", function (event) {
var ID = $(".rank").val();
console.log("Loading rank: " + ID);
loadData(ID);
});
function loadData(ID) {
var getRank = ID;
var dataString = 'getRank=' + getRank;
$.ajax({
type: "POST",
url: "otherTest.php",
data: dataString,
cache: false,
success: function (html) {
$("#txt_out").append(html);
}
});
}
</script>
</head>
<body>
<h1>Get Mens Rankings</h1>
<input value="233" class="rank" />
<button class="go">Get stats</button>
<textarea readonly="readonly" id="txt_out"></textarea>
</body>
</html>
and upon clicking the 'get stats' button, it calls (through AJAX) this page:
<?php
include_once ('simple_html_dom.php');
$rank = $_POST['getRank'];
$URL = "http://fifa.com/worldranking/rankingtable/gender=m/rank=".$rank."/confederation=25998/page=1/_ranking_table.html";
$html = file_get_html($URL);
$test = trim($html->find('.rnkdate', 0)->innertext);
echo "Date published: " . $test;
?>
It's trying to extract the date published from this URL: http://www.fifa.com/worldranking/rankingtable/gender=m/rank=233/confederation=25998/page=1/_ranking_table.html
where rank=XXX
is a different table for a different month.
Anyway, when I do this, here's what I get:
The problem is that it's inside another DIV and thus... I guess it doesn't show inside a <textarea>
. So... how do I get inside that div and extract the text itself? Thank you.