PHP Classes

File: examples/demo_10.php

Recommend this page to a friend!
  Classes of J.   HTML SQL   examples/demo_10.php   Download  
File: examples/demo_10.php
Role: Example script
Content type: text/plain
Description: Example 10 - Shows how to use the "isolate_content" function
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 17 years ago
Size: 1,422 bytes
 

Contents

Class file image Download
<?php

   
/*
    ** htmlSQL - Example 10
    **
    ** Shows how to use the "isolate_content" function
    */

   
include_once("../snoopy.class.php");
    include_once(
"../htmlsql.class.php");
   
   
$wsql = new htmlsql();
   
   
// connect to a URL
   
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/')){
        print
'Error while connecting: ' . $wsql->error;
        exit;
    }
   
   
/*
    ** The isolate_content functions works like the select function,
    ** but you can specify custom HTML parts, the content between
    ** these two strings will be used for the query process
    **
    ** In this case we select all content between "<h1>New snippets</h1>"
    ** and "<p id="rss">" this returns all snippet links, and no other links
    ** (like header or navigation links)
    */

   
$wsql->isolate_content('<h1>New snippets</h1>', '<p id="rss">');
   
   
/*
        other examples:
   
        $wsql->isolate_content('<body>', '</body>');
        $wsql->isolate_content('<!--content:start-->', '<!--end-->');
    */
   
    /* execute a query:
      
       This query returns all links:
    */
   
if (!$wsql->query('SELECT * FROM a')){
        print
"Query error: " . $wsql->error;
        exit;
    }

   
// fetch results as array
   
foreach($wsql->fetch_array() as $row){
   
       
print_r($row);
       
    }
   
?>