PHP Classes

File: test_scraper.php

Recommend this page to a friend!
  Classes of Antonio Rodrigues   PHP Scraper   test_scraper.php   Download  
File: test_scraper.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP Scraper
Extract structured data from remote HTML pages
Author: By
Last change:
Date: 19 years ago
Size: 654 bytes
 

Contents

Class file image Download
<?
require_once ("class_scraper.php");

// Get html --------
$o_sc = new scraper();
$s_url = 'http://finance.yahoo.com/q/hp?s=AMZN';
$s_user_agent = 'Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020921 Netscape/7.0';
$s_html = $o_sc->browse($s_url, $s_user_agent);

// Delimit start and end of patterns
$s_start_pattern = "Adj Close";
$s_end_pattern = "<small>";

// Pattern structure
$s_model = '<tr
<td
<field>
</td>
<td
<field>
</td>
<td
<field>
</td>
<td
<field>
</td>
<td
<field>
</td>
<td
<field>
</td>
<td
<field>
</td>
/tr>'
;

$a_result = $o_sc->extract($s_html, $s_start_pattern, $s_end_pattern, $s_model);
print_r ($a_result);

?>