If possible, it would probably be better if you used the CURL functionality now a part of PHP (you need to download and install libcurl first, though). See this page for more information. Libcurl support in PHP is much better than this browser class. If you can't use libcurl, you can still use this, though. ;-)
class.browser.php is a class of functions that is designed to make it easy to download web pages for numerous uses, including for web crawling. It extends the functionality of the PHP function fsockopen, as well as adds string parsing functions to make numerous jobs easier.
[[[ Latest version: .09 ]]] -- now you can pass cookies to the server
$browser = new Browser;
$r = $browser->get_url($array);string URL, string req_mthd (default GET), string content (used only for sending POST data), array cookies (keyed array, key=>value of cookie. Even if only one cookie, it needs to be an array), string protocol (default HTTP/1.0), string referer, string user_agent (default 'PHP3 Browser'), boolean robot_rules (TRUE or FALSE, attempts to follow robots.txt standard), string timeout (default 20 seconds)Example:
$page = $browser->get_url(array(
"url"=>"http://www.foobar.com/",
"req_mthd"=>'GET',
"protocol"=>'HTTP/1.1',
"cookies"=>array("haircolor"=>"green"),
"user_agent"=>"My Green Head",
"referer"=>"http://www.here.com",
"robot_rules"=>TRUE,
"time_out"=>15
)
);
result $r is an array, with four members:
function get_headers(string raw_headers)
Pass this function the raw headers received in $page["headers"]. Result is keyed associative array. Key is lower case header name, with all dashes (-) replaced with underscores (_). Value is value of header. For instance, the header Content-type: text/html would be:
print $hash["content_type"] (output would be text/html)function get_links(string web_page, string $url)
Pass this function the web page, and it will find all the links and return them in an array. If you pass this function a second argument, the URL of the page whose content you are sending, it will turn relative links into absolute links, thus:
$url is http://www.website.com/~user/index.html -> http://www.website.com/~user/index.html ../charlies/angels.html -> http://www.website.com/charlies/angels.html
function get_page_title(string web_page)
Pass function unparsed web page, returns a string of the <title>Title</title> of the page.
function get_meta_tags(string web_page)
Pass function unparsed web page, returns keyed associative array of all (if any!) meta tags on page. Note that you should check $hash for is_array ( like: if(is_array($hash)) ) before proceeding to any PHP each() function for output, or else you'll error out. Key is lower case name of meta tag, value is content of meta tag.
<meta name="Keywords" content="government auctions, GOVERNMENT AUCTIONS,boats cars vehicles computers">