0
<?php
  $html = file_get_contents('http://xpool.xram.co/index.cgi');
  echo $html;
?>

I want to get information in a tag on a remote web site using php. and only the tags.

I found this small string that is great for retrieving the entire site source. However, i want to get a small section only. How can I filter out all the other tags and get only the one tag I need?

Konsole
  • 3,447
  • 3
  • 29
  • 39

1 Answers1

1

I'd suggest using a PHP DOM parser. (http://simplehtmldom.sourceforge.net/manual.htm)

require_once ('simple_html_dom.php');

$html = file_get_contents('http://xpool.xram.co/index.cgi');

$p = $html->find('p'); // Find all p tags.

$specific_class = $html->find('.classname'); // Find elements with classname as class.

$element_id = $html->find('#element'); // Find element with the id element

Read the docs, there are tons of other options available.

Gilly
  • 9,212
  • 5
  • 33
  • 36