# Unit simpleinternet

Description
Uses
Classes, Interfaces, Objects and Records
Functions and Procedures
Types
Constants
Variables

## Description

This unit contains a very simple procedural interface to make http requests and process the returned data.

To get started, you can just use the function retrieve('...url...') to get the data you need as a string.

Retrieve also supports file:// urls or other data source; if you want to restrict it to http GET/POST-requests only, you can use the httpRequest function.

The data can then be processed with process which applies an XPath/XQuery expression or a html template to it.

Example

Get all links on a page:

    for v in process('http://www.freepascal.org', '//a') do
      writeln(v.toString, ' => ', v.toNode['href']);

## Overview

### Functions and Procedures

`function retrieve(data: string): string;`
`function httpRequest(url: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
`function httpRequest(url: string; rawpostdata: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
`function httpRequest(url: string; postdata: TStringList): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
`function httpRequest(const method, url, rawdata: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
`function httpRequest(const destination: xquery.IXQValue): string; overload; deprecated 'Use destination.retrieve() instead.';`
`function process(data: string; query: string): xquery.IXQValue;`
`function processedTree: TTreeNode;`
`function processedVariables: TXQVariableChangeLog;`
`procedure freeThreadVars;`
`function defaultInternet: TInternetAccess; inline;`
`function defaultQueryEngine: TXQueryEngine; inline;`
`procedure needInternetAccess; deprecated 'This procedure no longer does anything';`

### Types

`IXQValue = xquery.IXQValue;`

## Description

### Functions and Procedures

`function retrieve(data: string): string;`
`Retrieve` data from any url. It is really simple to use, you pass the desired url as single parameter and get the data of the url. It supports: http://... https://... file://... /normal/unix/file/paths C:\normal\windows\paths <html>data</html>

`function httpRequest(url: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
Warning: this symbol is deprecated: The httpRequest functions have been moved to the internetaccess unit.

`function httpRequest(url: string; rawpostdata: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
Warning: this symbol is deprecated: The httpRequest functions have been moved to the internetaccess unit.

`function httpRequest(url: string; postdata: TStringList): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
Warning: this symbol is deprecated: The httpRequest functions have been moved to the internetaccess unit.

`function httpRequest(const method, url, rawdata: string): string; overload; deprecated 'The httpRequest functions have been moved to the internetaccess unit.';`
Warning: this symbol is deprecated: The httpRequest functions have been moved to the internetaccess unit.

`function httpRequest(const destination: xquery.IXQValue): string; overload; deprecated 'Use destination.retrieve() instead.';`
Warning: this symbol is deprecated: Use destination.retrieve() instead. Make a http request to an address given in an IXQValue. node: if a link (a), download @href. If a resource (img, frame), download @src. Otherwise download the text . object: Download obj.url, possibly sending obj.post as postdata. else: Download the string value.

`function process(data: string; query: string): xquery.IXQValue;`
Processes data with a certain query. data can be an url, or a html/xml file in a string, like in retrieve. query can be a `xquery.TXQueryEngine`, like in `process('http://www.google.de', '//title');`. Or query can be a html template like `process('http://www.google.de', '<title><t:s>result:=text()</t:s></title>');` The advantage of such templates is that they can return several variables at once and a canonical representation of the same data on different web sites. To get a list of all variables of the last query you can use processedVariables. This function returns an IXQValue value, which is a variant for XQuery expression. If you want a string value, you can convert it like `process(...).toString`. Or if you want to access a retrieved node directly, you can use `process(..).toNode`. It can also contain multiple values, which can be access like `for x in process(..)`, where x is another IXQValue. The global function processedTree returns a tree representation of the last processed data string.

`function processedTree: TTreeNode;`
Returns a tree representation of the last processed html/xml data Might return nil

`function processedVariables: TXQVariableChangeLog;`
Returns all variable assignments during the last query

`procedure freeThreadVars;`
If you use the functions in this unit from different threads, you have to call `freeThreadVars` before the thread terminates to prevent memory leaks This also calls `freeThreadVars` of the xquery and internetaccess units

`function defaultInternet: TInternetAccess; inline;`

`function defaultQueryEngine: TXQueryEngine; inline;`

`procedure needInternetAccess; deprecated 'This procedure no longer does anything';`
Warning: this symbol is deprecated: This procedure no longer does anything

### Types

`IXQValue = xquery.IXQValue;`
IXQValue from the xquery unit. Just a wrapper, so that no other unit needs to be included

Generated by PasDoc 0.16.0.