-3

Possible Duplicate:
How to parse and process HTML with PHP?

<body> 
    <table align="center">

<?
 $ip=$_SERVER['REMOTE_ADDR'];
 $url=file_get_contents("http://whatismyipaddress.com/ip/$ip");
 preg_match_all('/<th>(.*?)<\/th><td>(.*?)<\/td>/s',$url,$output,PREG_SET_ORDER);
 for ($q=0; $q < 25; $q++) {
    if ($output[$q][1]) {
        if (!stripos($output[$q][2],"Blacklist")) {
            echo "<tr><td>".$output[$q][1]."</td><td>".$output[$q][2]."</td></tr>";

        }
    }
}
?> 
    </table>
</body> 

Now, with this code I get a lot of information like isp,country, etc.

How can I extract the content so that I load them into my database like $country , $isp , etc? I think it can be done if it's converted to xml but I'm not sure.

Community
  • 1
  • 1
user889030
  • 4,353
  • 3
  • 48
  • 51

1 Answers1

2

You are looking for PHP Simple HTML DOM Parser

Using that you can :

$html = file_get_html('http://www.google.com/');

and later from html using functions defined in parser like find and others get individual tags..

Read this

Rajat Singhal
  • 11,234
  • 5
  • 38
  • 56