Aditya J.
Aditya J.

Reputation: 131

Perl LWP: Submitting a Query - Error 400 URL must be absolute

I need to create a script that accesses a website, submits a query, 'clicks' on one of the hits, and sends back the url of the result. What I'm stuck on is submitting the query in the first place. Here is what I have:

use strict;
use warnings;
use LWP::UserAgent;
my $entry = $ARGV[0] or die;
my $url = 'http://genome.ucsc.edu/cgi-bin/hgBlat?hgsid=502819467_w6Oj12MTSqOIIJuSjAKsza4x9yeA&command=start';
my $browser = LWP::UserAgent->new;
my $response = $browser->post(
  '$url',
  [
    'sequence'  => $entry,
    'search' => 'submit'
  ],
);
die "Error: ", $response->status_line
 unless $response->is_success;

I keep getting this error: Error: 400 URL must be absolute at LWPtest.pl line 14. Can someone explain what this means, and how I should fix the problem? Also how do I approach the "'clicks' on one of the hits, and sends back the url of the result" bit?

EDIT:

I found this on the website in question:

When including a Genome Browser URL, please remove the hgsid parameter. It is an internally-used parameter that expires after about a day.

Not sure if this is part of the problem; it may become a problem after "about a day".

Upvotes: 0

Views: 7013

Answers (2)

Tim Tom
Tim Tom

Reputation: 809

$url on line ~10 in single quotes, which means that it is the character sequence $ u r l instead of the value of the variable $url.

'$url',

to

$url,

Upvotes: 1

ikegami
ikegami

Reputation: 385764

The code

'$url'

produces the 4-character string

$url

instead of

http://genome.ucsc.edu/cgi-bin/hgBlat?hgsid=502819467_w6Oj12MTSqOIIJuSjAKsza4x9yeA&command=start

Simply replace

'$url'

with

$url

Upvotes: 1

Related Questions