PHP Classes

PHP Scrape HTML: Retrieve and extract data from remote sites

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 370 This week: 1All time: 6,807 This week: 560Up
Version License PHP version Categories
scrape 1.0.1MIT/X Consortium ...5PHP 5, Text processing, Web services
Description 

Author

This class retrieve and extract data from remote sites.

It can send a HTTP request to retrieve data from a remote site or use a given string from a local file.

The class can extract text that is contained between a given prefix or suffix strings.

The search for the strings can be made from the retrieved data start or end.

Picture of Matthew Boyle
  Performance   Level  
Name: Matthew Boyle <contact>
Classes: 6 packages by
Country: United States United States
Age: ???
All time rank: 1963276 in United States United States
Week rank: 411 Up48 in United States United States Up
Innovation award
Innovation award
Nominee: 3x

Example

<?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";
}

?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Sample usage
Plain text file scrape.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 0%
Total:370
This week:1
All time:6,807
This week:560Up