I'm trying to grab/fetch text from another URL using cURL. The location of where I grab the text from is within a blank HTML document with dynamic (not static) data, therefore there are no HTML tags to filter. This is what I've got so far:
$c = curl_init('http://url.com/dataid='.$_POST['username']);
curl_setopt(CURLOPT_RETURNTRANSFER, true);
curl_setopt(CURLOPT_FRESH_CONNECT, true);
$html = curl_exec($c);
if (curl_error($c))
die(curl_error($c));
// Get the status code
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
This works perfectly, however at the end of dynamic HTML document there is un-required text, "#endofscript" (without quotations). This gets grabbed/fetched, so what can be done to not grab that? I've tried looking at "strpos" and such but I'm unsure on how to integrate that with cURL.
All/Any help will/would be appreciated. :)
EDIT: The code I'm currently using:
<?php
$homepage = file_get_contents('http://stackoverflow.com/');
$result = substr("$homepage", 0, -12);
echo $result;
?>