PHP_Robot_Class
[ class tree: PHP_Robot_Class ] [ index: PHP_Robot_Class ] [ all elements ]

Class: Robot

Source Location: /robot-class.php

Class Overview


This script is a robot class to help you make web robots to crawl the web.


Author(s):

Version:

  • 2.0

Copyright:

  • Copyright (C) 2005, Sam Clarke. All rights reserved.

Methods



Class Details

[line 31]
This script is a robot class to help you make web robots to crawl the web.



Tags:

copyright:  Copyright (C) 2005, Sam Clarke. All rights reserved.
version:  2.0
author:  Sam Clarke <admin@free-php.org.uk>
license:  GNU Public License


[ Top ]


Class Methods


method GetEverything [line 116]

bool GetEverything( string $url)

Gets everything from a server and stores it in a string

Gets everything that was sent back by the server and stores it in a string for the rest of the functions to use so that you only have to request a page once to be able to run all the functions. Must be called before any of the other functions will work!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. ?>




Tags:

return:  It will return true also long as it opens a connection to the server no matter what the status code is.


Parameters:

string   $url   The url to open and get the contents of.

[ Top ]

method GetHeaders [line 272]

mixed GetHeaders( )

Gets the headers returned from the server.

Gets the headers returned from the server. You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. echo $robot->GetHeaders();
  5. ?>




Tags:

return:  returns a string of headers or false.


[ Top ]

method GetHTML [line 303]

mixed GetHTML( )

Gets the HTML returned from the server.

Gets all the HTML returned from the server. You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. echo $robot->GetHTML();
  5. ?>




Tags:

return:  returns a string of HTML or false.


[ Top ]

method GetStatus [line 68]

mixed GetStatus( )

Gets the status code returned from the server

Gets the status code that was returned from the server. You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. echo $robot->GetStatus();
  5. ?>




Tags:

return:  returns false on fail and status code on sucsess


[ Top ]

method GetTEXT [line 335]

mixed GetTEXT( )

Gets the text from a web page with the HTML striped.

Gets the text from a web page with all of the HTML striped off. You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. echo $robot->GetTEXT();
  5. ?>




Tags:

return:  returns a string or false.


[ Top ]

method GetUrls [line 209]

mixed GetUrls( string $url)

Gets an array of urls from the web page.

Gets an array of urls from the web page in temp_everything; You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. print_r($robot->GetUrls('http://www.free-php.org.uk/'));
  5. ?>




Tags:

return:  returns an array of urls or false.


Parameters:

string   $url   The url that that page is from

[ Top ]

method ReturnEverything [line 183]

mixed ReturnEverything( )

Gets everything that was returned from the server.

Gets everything that was sent back from the server with the complete headers and HTML. You must call the function GetEverything first!

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->GetEverything('http://www.free-php.org.uk/');
  4. echo $robot->ReturnEverything();
  5. ?>




Tags:

return:  returns what ever is in temp_everything.


[ Top ]

method SetAgent [line 382]

void SetAgent( string $agent)

Sets the user agent name.

Sets the name of the user agent to send to the server when asking for a web page.

Below is an example:

  1. <?php
  2. $robot = new Robot;
  3. $robot->SetAgent('Pinky and the Brain');
  4. ?>




Parameters:

string   $agent   The name of the user agent to set.

[ Top ]


Documentation generated on Sun, 02 Oct 2005 18:12:41 +0100 by phpDocumentor 1.3.0RC3