1

So I've got this:

$pageurl = "http://www.example.com";
$group = $_POST['group'];
$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $pageurl);
curl_setopt($ch, CURLOPT_POSTFIELDS, "group=$group");
$result = curl_exec ($ch);
curl_close($ch);

Which returns a web page. What I want to do is display only a certain part of that page, for example a single table. How would I go about that?

2 Answers2

1

You can try this library PHP Simple HTML DOM Parser

Waqar Alamgir
  • 9,828
  • 4
  • 30
  • 36
0

Provided code seems incorrect - before

curl_setopt($ch, CURLOPT_POSTFIELDS, "group=$group");

you should specify

curl_setopt($ch, CURLOPT_POST, true);

to make sure your cURL HTTP POST request is going to be established correctly. (otherwise HTTP GET is default)

To extract parts of returned HTML document, best way is by using strip_tags() function http://php.net/manual/en/function.strip-tags.php, which will clear your code from any parts of HTML you do not want.

Miloš Đakonović
  • 3,751
  • 5
  • 35
  • 55