0
<?php

$url = 'http://url.com/usersvalue.html/';

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);


print ($result);


?>

I'm trying to make a script which only outputs a specific line from a website, and that line is html and its

"<td>users</td><td>100</td>"

. I'm trying output the value of "<td>100</td>" which is 100 at this point, each time the value changes on the $url website..

the html of the $url website:

<html><head></head><body style='font-family:Verdana'>
<h2>Status</h2><hr>
<table cellpadding='6' cellspacing='0' border='0'>
<tr bgcolor='#eeeeee'><th align='left'>Key</th><th align='left'>Value</th></tr>
<tr>
<td>users</td><td>100</td>
</tr>
<tr>
<td>uptime</td><td>00</td>
</tr>
<tr>
<td>zones</td><td>0</td>
</tr>
<tr>
<td>rooms</td><td>0</td>
</tr>
<tr>
<td>version</td><td>0</td>
</tr>
</table><hr>
</body></html>
3
  • Please show more clue, maybe your victim or structure of HTML content. I will help you Commented Jul 19, 2016 at 19:34
  • added the html content. Commented Jul 19, 2016 at 19:36
  • Try my source bro xD Commented Jul 19, 2016 at 19:47

1 Answer 1

2

You can use my source

function getStr($string,$start,$end){
    $str = explode($start,$string,2);
    $str = explode($end,$str[1],2);
    return $str[0];
}
echo getStr($result,'<td>users</td><td>','</td>');

OR

if (!preg_match('#<td>users</td><td>([0-9]+)</td>#', $result, $result_preg)) { 
    die('bad dsid'); 
}else{
    echo $result_preg[1];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.