newsclipperdevlist  

Re: Alternative to URL - POST?

David Coppit
Mon, 11 Sep 2000 10:17:13 -0700

On Mon, 11 Sep 2000, John Menke wrote:

> A2007 represents the Symbol in this query string.    I cannot figure out how
> to convert TIVO into A2007... so I was wondering if instead of specifying a
> URL for the handler to get information from if I could specify the
> parameters to a post operation and have the handler do a post.

You can do anything that you can do in Perl.

I suggest building a request using HTTP::Request::Common, which has a
POST method. You can then send the request using the same user agent
that News Clipper uses:

-------------------
[begin untested code]
use HTTP::Request::Common qw( POST );
...

sub Get
{
  ...
  my $loginUrl='http://www.altavista.com/cgi-bin/query';

  my $query = 'query text';

  my $loginReq = POST($loginUrl, [ q => $query ]);

  # Make a local $userAgent that aliases to the one in
  # NewsClipper::AcquisitionFunctions
  *userAgent = \$NewsClipper::AcquisitionFunctions::userAgent;

  # Do the request
  my $result = $userAgent->request($loginReq)->as_string();

  # Return a reference to a string (or do something with the string)
  return \$result;
}
-------------------

It's probably better to generalize this code and make it part of
AcquisitionFunctions. If you can come up with something that makes
sense, I'll roll it into the next release. Otherwise, feel free to
write your handler any way you want. :)

David

____________________________________________________________________________
David Coppit <[EMAIL PROTECTED]>        President, Spinnaker Software
http://www.newsclipper.com/ -- Snip and ship dynamic content to your website


-
If you would like to unsubscribe from this mailing list send an email to 
[EMAIL PROTECTED] with the body "unsubscribe newsclipperdevlist 
YOUR_EMAIL_ADDRESS" (without the quotes) or use the form provided at 
http://www.NewsClipper.com/TechSup.htm#MailingList.