PHP Classes

PHP Scrape HTML: Retrieve and extract data from remote sites

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 370 All time: 6,815 This week: 524Up
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
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 (2)  
File Role Description
Accessible without login Plain text file example.php Example Sample usage
Plain text file scrape.class.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:370
This week:0
All time:6,815
This week:524Up