PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Matthew Boyle   PHP Scrape HTML   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Sample usage
Class: PHP Scrape HTML
Retrieve and extract data from remote sites
Author: By
Last change:
Date: 7 years ago
Size: 487 bytes
 

Contents

Class file image Download
<?php

include( 'scrape.class.php' );

$info = new Scrape('http://www.zip-codes.com/search.asp?fld-city=Lansing&fld-state=MI&selectTab=2&Submit=Find+ZIP+Codes');
$rows = $info->split('techHover',0,1);

foreach(
$rows as $row ){
   
$zip = $info->extractText($row, '.asp">');

   
// some string manipulation to get what you want
   
$cty = $info->extractText( substr($row, strpos($row, '/county')), '.asp">' );

    echo
"ZIP Code: {$zip} is in the county of {$cty}<br />\r\n";
}

?>