Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is more of a basic html/http question but it involves perl also. I am trying to get the contents of a web page that uses the POST method along with a few header/value pairs. When I put the following URL into my browser the resulting page is empty. I am not sure what I am doing wrong. My URL is based on the HTML form that I found in the source code. What am I missing? So this is how I am submitting my info:

http://x.x.x.x/cgi-bin/rgcgi?type=DisplayRoute&table=IPtoPSTNRoute&phonenumbermatch=A1212

This is what I see in an ethereal trace

Line-based text data: application/x-www-form-urlencoded

type=DisplayRoute$table=IPtoPSTNRoute&phonenumbermatch=A1212

Here is the html form:


Display IPtoPSTNRoute

<form action="rgcgi?action=IPtoPSTNRoute" method="post"> <input type="hidden" name="type" value="DisplayRoute"> <input type="hidden" name="table" value="IPtoPSTNRoute">Phonenumber Match: <input type="text" name="phonenumbermatch">   <input type="submit" value="Display Routes"></form>
This is what my code looks like
#!/usr/bin/perl require LWP::UserAgent; use HTTP::Request::Common; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $response = $ua->request(POST 'http://x.x.x.x/cgi-bin/rgcgi', [ type => DisplayRoute, table => IPtoPSTNRoute, phonenumbermatch => 'A1212' ]); if ($response->is_success) { print $response->content; # or whatever } else { die $response->status_line; }

In reply to using LWP to POST multiple name/value pairs by atistler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-29 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found