/** * Scrape URL * * Loads down a page of HTML, and runs it against a regex expression. * The results are retuned as an array, or as an object if matched names are provided. * * @param String $url The complete URL to the target page (http://www.example.com/) * @param String $regex The regex pattern to test against * @param Array $match_names An array of strings that will become the names of the object properties * @param Array $options Any additional options for cURL * * NB: $match_names need to be in the same order as the parenthesised sections of the regex pattern * (eg. array( 'foo', 'bar' ) will become $object->foo, $object->bar, in that order) */ static function scrape_url($url = '', $regex = '', $match_names = NULL, $options = NULL) { //create cURL class require_once 'curl.class.php'; $curl = new cURL(); //insert any additional options into cURL if (is_array($options)) { $curl->options($options); } //grab the HTML data $html = $curl->get($url); //scrape HTML return PageScraper::scrape_html($html, $regex, $match_names); }