basic LWP babelfish - "brittleness"? 
Author Message
 basic LWP babelfish - "brittleness"?

allo Kind Folks,

I've been going through all the examples in Sean M. Burke's recent
"Perl & LWP" book (which i'm very happy with, and would quickly
recommend), but i think i've hit an example of what Mr Burke
refers to as "brittleness" (having the website change under your
efforts to deal with it programmatically).

Has anyone discovered how to correct what seems to be babelfish's
new(?) tendency to return the exact phrase 'post'ed to it, rather
than return a translation?

(for instance, via "alienate.pl" :
      http://www.*-*-*.com/ )

I've even tried changing UserAgent in case they've become annoyed
at people using LWP (see appended simple example (even a "works
for me" would be very instructive - thank you))

Many thanks indeed!

#!/usr/bin/perl
# ---- from Sean Burke 'Perl and LWP' book)
use LWP;
use strict;

my $browser;
sub do_POST {
  $browser = LWP::UserAgent->new() unless $browser;
  $browser->agent('Mozilla/4.76 [en] (Win98; U)');


  return($resp->content, $resp->status_line, $resp->is_success, $resp)
    if wantarray;
  return unless $resp->is_success;
  return $resp->content;

Quote:
}

my ($content, $message, $is_success) = do_POST(
    ' http://www.*-*-*.com/ ',
    [ 'urltext' => "I like pie", 'lp' => 'en_fr', 'enc' => 'utf8' ],
  );

die "Error in translation en_fr: $message\n"
  unless $is_success;

for (split("\n",$content)) {
  print if(/textarea/);

Quote:
}

--
jeff


Fri, 21 Jan 2005 06:09:29 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. basic "open" question

2. Basic question about "closedir"

3. How to emulate BASIC "pack"

4. "LWP::Authen::Ntlm" (perhaps you forgot to load "LWP::Authen::Ntlm"?

5. "character class ""bug""

6. Secure "GET" Requests using LWP

7. "LWP not available"

8. LWP error: "url must be absolute"

9. "make test" problem in LWP (libwww)

10. unable to system("lwp-rget")

11. help: "LWP from CPAN" (CGI-Unix)

 

 
Powered by phpBB® Forum Software