19.7 Win32::InternetThe Win32::Internet extension implements the Win32 Internet APIs (found in WININET.DLL ), providing support for HTTP, FTP, and Gopher connections. All types of connections start as a basic Internet connection that must be opened with the following command: This creates an Internet object in Perl on which you use the functions provided in this module to create more specific connection objects. The objects and functions that create them are:use Win32::Internet; $Connection = Win32::Internet->new();
This module provides different levels of implementation of the Win32 Internet functions. Some routines use several Win32 API functions to perform a complex task in a single call; they are simpler to use, but less powerful. Other functions implement nothing more and nothing less than the corresponding API function, so you can use all of their power, but with some additional programming steps.
For example, the function You can achieve the same result with this series of commands, which is what$inet = new Win32::Internet(); $file = $inet->FetchURL("http://www.yahoo.com");
FetchURL
actually does:
$inet = new Win32::Internet(); $url = $inet->OpenURL("http://www.yahoo.com"); $file = $url->ReadFile(); $url->Close(); 19.7.1 General Internet Methods
The methods described in this section are used on Internet connection
objects created with You can supply$inet = Win32::Internet->new();
new
with an optional list of arguments (or a reference to a hash containing them)
that looks like this:
The parameters and their values are:Win32::Internet->new [ useragent , opentype , proxy , proxybypass , flags ] Win32::Internet->new [ $hashref ]
If you pass a hash reference to the function, the following values are taken from the hash: The following methods can be used on Internet connection objects:%hash=( "useragent" => "useragent", "opentype" => "opentype", "proxy" => "proxy", "proxybypass" => "proxybypass", "flags" => flags, );
19.7.2 FTP Functions
The methods described in this section are used to control
FTP sessions. They apply to FTP session objects created by
the The following methods are used on FTP session objects:use Win32::Internet; $inet = new Win32::Internet(); $inet->FTP($FTP, "hostname", "username", "password"); 19.7.3 HTTP Functions
The methods described in this section are used to create and
control an HTTP session. You open an HTTP session using the
This opens the session and creates the HTTP session objectuse Win32::Internet; $inet = new Win32::Internet(); $inet->HTTP($http, "hostname", "username", "password");
$http
. The following methods can be used on HTTP session objects:
|
|