Hi there Monks,
I need to access a database through a HTTP interface. It all start with getting a login token to get going. Using a webbrowser or curl on the command line I can do this quite effortless
On a curl request:
I get back a piece of HTML:curl 'https://somesite:8800/?library=Algemeen&function=Login&UserName= +SomeUser&Password=SomePass'
<table><tr><td><b>Result</b></td><td ID="Result">True</td><tr><tr><td> +<b>ResultMessage</b></td><td ID="ResultMessage"></td><tr><tr><td><b>S +essionToken</b></td><td ID="SessionToken">sometoken</td><tr></table>
just as I expected. So I went ahead and made a small script with LWP doing the same thing:
But alas... this returns a webpage instead of the table structure like it did with curl.#! /usr/bin/perl -w use strict; use HTTP::Request; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $url = 'https://somesite:8800/'; my $req = HTTP::Request->new(POST => $url); $req->content_type('application/x-www-form-urlencoded'); $req->content('library=Algemeen&function=Login&UserName=SomeUser&Passw +ord=SomePass'); my $res = $ua->request($req); if ($res->is_success){ print $res->content; }else{ print $res->status_line, "\n"; }
What is the difference between the curl example and the LWP example? Im kinda at a loss with this
Peter
In reply to LWP and Curl results differ by PeterKaagman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |