473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Posting a html form using LWP

4
Anyone could help me out for n=my code ......I have written following code ,Here i m able to get and post the form successfuly..but after posting im not gettng proper response content...

#!usr/bin/perl -w
use strict;
use LWP;
use LWP::Simple;
use LWP::UserAgent;
use HTML::Form;
use Switch;
use HTTP::Cookies;
#use HTTP::Headers;
my $name = "";
my $url='https://192.168.2.24:10443/index.php';
my $usr_agent = new LWP::UserAgent;
$usr_agent->env_proxy;
#my $browser = LWP::UserAgent->new(agent =>'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461)',
# 'cookie_jar' => {file => "lwpcookies.txt", autosave => 1,ignore_discard => 1});

#Request the page

my $req = new HTTP::Request('POST', 'https://193.168.2.24:10443/index.php');
my $cookie_jar = HTTP::Cookies-> new( file => "cookie.txt",
autosave => 1,
ignore_discard => 1
);
$usr_agent->cookie_jar($cookie_jar);
my $response = $usr_agent->request($req);

# my $response =$browser->get($url);

my $my_string1 = $response->content;
open(OUT,">web_request.txt");
print OUT $my_string1;
close OUT;
#my @forms = HTML::Form->parse($response);
if (!($response->is_success))
{
print "Cannot get $url: ", $response->status_line, "\n";
}
if ($usr_agent->cookie_jar->as_string)
{ # they set cookies
print "///////////////////////////////";
print "use HTTP::Cookies; $usr_agent->cookie_jar(HTTP::Cookies->new)", "\n";
# to set cookies
print "$usr_agent->request($req)","\n";
print "///////////////////////////////";

}
# my $abb = $cookie_jar->extract_cookies($response);
my @forms = HTML::Form->parse($response);#parse the form got by request
my @inputs = $forms[0]->inputs; #parse all the input tags
my %parsed_inputs = ();
my %parsed_actions = ();
my %parsed_checks = ();
my %parsed_others = ();
foreach my $input(@inputs)
{
$name = $input->name;
my $input_type = $input->type;
switch($input_type)
{
case "text" { $parsed_inputs{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "password" {$parsed_inputs{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "option" {$parsed_inputs{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "button" {$parsed_actions{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "reset" {$parsed_actions{ $name } = {
value => $input->value,
type => $input->type,
};
}

case "submit" {$parsed_actions{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "checkbox"{$parsed_checks{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "radio" {$parsed_checks{ $name } = {
value => $input->value,
type => $input->type,
};
}
else {$parsed_others{ $name } = {
value => $input->value,
type => $input->type,
};
}#file/hidden/image
}
}
my $req1 = new HTTP::Request('POST',$url,['uname' =>'jitu@mwti.net',
'pass'=>'jitu123',
'login'=>'Login', ]);

my $respons = $usr_agent->request($req1);
my $my_string = $respons->content;
open(OUT,">web_response.txt");
print OUT $my_string;
close OUT;
Jan 10 '07 #1
0 2534

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
10
by: DaveFash | last post by:
Posting variables from an HTML FORM, via the Request.Form function on the receiving ASP page is great. But how can you POST a Form variable to an ASP page -- without a human pushing a Submit...
13
by: Ian.Suttle | last post by:
I am have been researching this issue to no end, so any help would be very much appreciated. I have a page with form tags. Inside of the form tags is a panel that contains a user control. The...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
2
by: Esa | last post by:
Hi, I'm having problems with one strange web system where submitting an application and making queries about its handling status require a series of form submits and response parsing - all in...
2
by: Peter2 | last post by:
Hi, I have a problem posting non-ASCII characters in FORM fields between classic ASP and ASP.NET. I use a fully patched Windows 2000 Advanced Server with .net 2.0 and visual Studio 2005 installed,...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: d3vkit | last post by:
I have a form on my page, and some javascript which uses ajax to submit the form, and then opens the new page in a div using ajax so there is no refresh. This works fine. But the problem is this: all...
5
by: Otto Wyss | last post by:
It's possible to declare inbut fields outside of a form, is it possible to post these values to the server? E.g. attach them to the posted form? O. Wyss
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.