Starts with a fresh browser with no cookie or any other state information. The exception is that a default proxy will be set up if specified in the options.
SimpleBrowser
SimpleBrowser
()
Adds a header to every fetch.
void
addHeader
(string $header)
-
string
$header: Header line to add to every request until cleared.
Ages the cookies by the specified time.
void
ageCookies
(integer $interval)
-
integer
$interval: Amount in seconds.
Retries a request after setting the authentication for the current realm.
boolean
authenticate
(string $username, string $password)
-
string
$username: Username for realm.
-
string
$password: Password for realm.
Equivalent to hitting the back button on the browser. The browser history is unchanged on failure.
boolean
back
()
Clears the frame focus. All frames will be searched for content.
void
clearFrameFocus
()
Clicks the submit image by some kind of label. Usually
the alt tag or the nearest equivalent. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
boolean
clickImage
(string $label, [integer $x = 1], [integer $y = 1])
-
string
$label: ID attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
Clicks the submit image by ID attribute. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
boolean
clickImageById
(integer/string $id, [integer $x = 1], [integer $y = 1])
-
integer/string
$id: ID attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
Clicks the submit image by the name. Usually
the alt tag or the nearest equivalent. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
boolean
clickImageByName
(string $name, [integer $x = 1], [integer $y = 1])
-
string
$name: Name attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
Follows a link by label. Will click the first link found with this link text by default, or a later one if an index is given. The match ignores case and white space issues.
boolean
clickLink
(string $label, integer $index)
-
string
$label: Text between the anchor tags.
-
integer
$index: Link position counting from zero.
Follows a link by id attribute.
boolean
clickLinkById
(string $id)
-
string
$id: ID attribute value.
Clicks the submit button by label. The owning form will be submitted by this.
boolean
clickSubmit
([string $label = 'Submit'])
-
string
$label: Button label. An unlabeled button can be triggered by 'Submit'.
Clicks the submit button by ID attribute of the button itself. The owning form will be submitted by this.
boolean
clickSubmitById
(string $id)
Clicks the submit button by name attribute. The owning form will be submitted by this.
boolean
clickSubmitByName
(string $name)
-
string
$name: Button name.
Equivalent to hitting the forward button on the browser. The browser history is unchanged on failure.
boolean
forward
()
Fetches the page content with a simple GET request.
string
get
(string/SimpleUrl $url, [hash $parameters = false])
-
string/SimpleUrl
$url: Target to fetch.
-
hash
$parameters: Additional parameters for GET request.
Accessor for a list of all fixed links in current page.
array
getAbsoluteUrls
()
Accessor for last Authentication type. Only valid straight after a challenge (401).
string
getAuthentication
()
Reads the current cookies for the base URL.
string
getBaseCookieValue
(string $name)
-
string
$name: Key of cookie to find.
Accessor for raw page information.
string
getContent
()
Reads the most specific cookie value from the browser cookies.
string
getCookieValue
(string $host, string $path, string $name)
-
string
$host: Host to search.
-
string
$path: Applicable path.
-
string
$name: Name of cookie to read.
Accessor for a form element value within the page.
Finds the first match.
string/boolean
getField
(string $name)
-
string
$name: Field name.
Accessor for a form element value within the page.
string/boolean
getFieldById
(string/integer $id)
-
string/integer
$id: Id of field in forms.
Accessor for current frame focus. Will be false if no frame has focus.
integer/string/boolean
getFrameFocus
()
Accessor for raw header information.
string
getHeaders
()
Accessor for current MIME type.
string
getMimeType
()
Accessor for last Authentication realm. Only valid straight after a challenge (401).
string
getRealm
()
Accessor for a list of all relative links.
array
getRelativeUrls
()
Accessor for raw bytes sent down the wire.
string
getRequest
()
Accessor for last response code.
integer
getResponseCode
()
Accessor for parsed title.
string
getTitle
()
Accessor for last error.
string
getTransportError
()
Fetches the page content with a HEAD request.
Will affect cookies, but will not change the base URL.
boolean
head
(string/SimpleUrl $url, [hash $parameters = false])
-
string/SimpleUrl
$url: Target to fetch as string.
-
hash
$parameters: Additional parameters for GET request.
Disables frames support. Frames will not be fetched and the frameset page will be used instead.
void
ignoreFrames
()
Tests to see if a link is present by label.
boolean
isLink
(string $label)
-
string
$label: Text of value attribute.
Tests to see if a link is present by ID attribute.
boolean
isLinkById
(string $id)
-
string
$id: Text of id attribute.
Fetches the page content with a POST request.
string
post
(string/SimpleUrl $url, [hash $parameters = false])
-
string/SimpleUrl
$url: Target to fetch as string.
-
hash
$parameters: POST parameters.
Removes expired and temporary cookies as if the browser was closed and re-opened.
void
restartSession
([string/integer $date = false])
-
string/integer
$date: Time when session restarted. If omitted then all persistent cookies are kept.
Equivalent to hitting the retry button on the browser. Will attempt to repeat the page fetch. If there is no history to repeat it will give false.
string/boolean
retry
()
Sets the socket timeout for opening a connection.
void
setConnectionTimeout
(integer $timeout)
-
integer
$timeout: Maximum time in seconds.
Sets an additional cookie. If a cookie has the same name and path it is replaced.
void
setCookie
(string $name, string $value, [string $host = false], [string $path = '/'], [string $expiry = false])
-
string
$name: Cookie key.
-
string
$value: Value of cookie.
-
string
$host: Host upon which the cookie is valid.
-
string
$path: Cookie path if not host wide.
-
string
$expiry: Expiry date.
Sets all form fields with that name.
boolean
setField
(string $name, string $value)
-
string
$name: Name of field in forms.
-
string
$value: New value of field.
Sets all form fields with that name.
boolean
setFieldById
(string/integer $id, string $value)
-
string/integer
$id: Id of field in forms.
-
string
$value: New value of field.
Sets the focus by name.
boolean
setFrameFocus
(string $name)
-
string
$name: Chosen frame.
Sets the focus by index. The integer index starts from 1.
boolean
setFrameFocusByIndex
(integer $choice)
-
integer
$choice: Chosen frame.
Sets the maximum number of redirects before a page will be loaded anyway.
void
setMaximumRedirects
(integer $max)
-
integer
$max: Most hops allowed.
Submits a form by the ID.
boolean
submitFormById
(string $id)
-
string
$id: The form ID. No submit button value will be sent.
Enables frames support. Frames will be fetched from now on.
void
useFrames
()
Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.
void
useProxy
(string $proxy, [string $username = false], [string $password = false])
-
string
$proxy: Proxy URL.
-
string
$username: Proxy username for authentication.
-
string
$password: Proxy password for authentication.
Creates a new empty history list.
Creates the underlying user agent.
SimpleFetcher
&_createUserAgent
()
Fetches a page.
SimplePage
&_fetch
(
string $method,
string/SimpleUrl $url,
hash $parameters,
boolean $add_to_history)
-
string
$method: GET or POST.
-
string/SimpleUrl
$url: Target to fetch as string.
-
hash
$parameters: POST parameters.
-
boolean
$add_to_history: Whether to record in the history.
Replaces missing form action.
Parses the raw content into a page. Will load further frame pages unless frames are disabled.