View Single Post
Old 11-06-2008, 12:51 AM   #5 (permalink)
Runar
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

Hello,

I made an attempt to solve your "problem", and I came up with the following (thanks to the manual) solution. I am sure there are better ways to do this, but this seems to work:
PHP Code:
<?php

// Create a new cURL resource
$ch curl_init();

// Set URL and other appropriate options
curl_setopt$chCURLOPT_URL'http://localhost/test.html' );
curl_setopt$chCURLOPT_HEADER);

// Start output buffering to capture page source
ob_start();

// Grab URL and pass it to the browser
curl_exec$ch );

// Close cURL resource, and free up system resources
curl_close$ch );

// Store content of output buffering to a variable
$cache ob_get_contents();

// Clean output buffer
ob_end_clean();

// Perform an expression match
preg_match"/<tr class=\"alternateRow\">[\s]+<td>([\w\d ,]+)<\/td>[\s]+<td>([\d\"\- ]+)<\/td>[\s]+<td>([\d\"\- ]+)<\/td>/im"$cache$matches );

// Print the matches
print_r$matches );
    
?>
It will find the following code, then put each of the three matches (it returns four matches, actually, including the entire string) into an array:
Code:
<tr class="alternateRow">
<td> Nov 4, 2008 </td>
<td> 4-6" </td>
<td> 8-10"</td>
We will end up with this (at least I did):
Code:
Array
(
    [0] => <tr class="alternateRow">
<td> Nov 4, 2008 </td>
<td> 4-6" </td>
<td> 8-10"</td>
    [1] =>  Nov 4, 2008 
    [2] =>  4-6" 
    [3] =>  8-10"
)
Let me know what you think, if it works and if there is anything you would do another way!


Yours,
Runar
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
The Following User Says Thank You to Runar For This Useful Post:
buildakicker (11-06-2008)