I’ve been working on this for the past few hours, and after going through tons of Google results, I still can’t get it to work.
I’m writing a perl script that connects to https://web5.uottawa.ca/rezweb/search.php, selects either “Off/On-Campus Accomodation”, clicks search, and prints the results.
Here is what I have so far:
#!/user/bin/perl
use strict; use warnings;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Crypt::SSLeay; #Since it's HTTPS
my $ua = LWP::UserAgent->new();
my $url = 'https://web5.uottawa.ca/rezweb/search.php';
my $formdata = ['accomodationType' => '1', 'submit' => 'Search'];
my $response = $ua->post($url, $formdata);
die "Error: ", $response->status_line . "\n"
unless $response->content;
Unfortunately, it’s still the page source of the form–not the search results page.
Related extra doc: Mojo::DOM.
I arrived at the POST parameter list by turning off JS—their site uses it for enhancement—and inspecting the request. While this solution works, it’s fragile. Make sure that you’re not violating the site’s ToS or abusing the form by hammering it.