473,766 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Posting a html form using LWP

4 New Member
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..bu t 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:10 443/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_discar d => 1});

#Request the page

my $req = new HTTP::Request(' POST', 'https://193.168.2.24:10 443/index.php');
my $cookie_jar = HTTP::Cookies-> new( file => "cookie.txt ",
autosave => 1,
ignore_discard => 1
);
$usr_agent->cookie_jar($co okie_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($respons e);
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(HTT P::Cookies->new)", "\n";
# to set cookies
print "$usr_agent->request($req)" ,"\n";
print "///////////////////////////////";

}
# my $abb = $cookie_jar->extract_cookie s($response);
my @forms = HTML::Form->parse($respons e);#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_t ype)
{
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_action s{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "reset" {$parsed_action s{ $name } = {
value => $input->value,
type => $input->type,
};
}

case "submit" {$parsed_action s{ $name } = {
value => $input->value,
type => $input->type,
};
}
case "checkbox"{$par sed_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.ne t',
'pass'=>'jitu12 3',
'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 2549

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

Similar topics

6
3264
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
10
4189
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 button? An ASP page that can decide when to POST and send the Form vaiables, but out without a
13
2752
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 form tags are NOT inside of the user control. Inside that user control are a few panels that contains different steps of an application (for applying to something). When I go to step 1 and submit, the asp:validators catch the errors and the...
7
17333
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 to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
2
2292
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 HTML. Luckily other interfaces are "modern" using xml file up/downloads without any difficulties... I'm not very used to .NET-environment yet, so I'd appreciate some clues about the classes I should use to implement this stupid interface - stupid...
2
7052
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, IIS, IE6 etc ... When an *.ASPX page receives the post, it drops non-ASCII characters, for example it drops character é from word Montréal. Specifying explicit encoding on ASP/ASPX page doesn't help. The encoding works without doing anything...
1
54531
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 we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
4
4983
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 values seem to pass except what the submit buttons say. I have a preview button and a finish button, and need to check which was pressed. I can add a checkbox for submit, but that's annoying. I'm using mootools for the ajax call, so it might not...
5
2717
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
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9837
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.