Reputation: 7012
I'm trying to fetch the date of the next episode of a specific tv show in this site using Mechanize in perl.
# getting episode number & date
# create a new browser
use WWW::Mechanize;
my $browser = WWW::Mechanize->new(autocheck => 0);
# fill search form, getting to tv show page
my $url= "http://next-episode.net/";
$browser->get($url);
$browser->form_name("search");
$browser->field("search", "big bang");
$browser->click();
print $browser->content();
I can't get to the tv show web-page. I only get the 404 page: "Sorry, the page you're looking for cannot be found! You may have typed a wrong url, or it may've been linked badly or moved."
am I filling the form wrongly?
Upvotes: 2
Views: 230
Reputation: 185073
What about this ? :
my $url = "http://next-episode.net";
my $search = "big bang";
use WWW::Mechanize;
use URI::Escape;
my $browser = WWW::Mechanize->new(autocheck => 1);
my $string = uri_escape $search;
$browser->get("$url/site-search-$string.html");
print $browser->content();
And if you'd like to know the number of days remaining to wait, add the extra line :
print "$1 days to wait\n" if $browser->content() =~ /(\d+)\s+Day\(s\)\s+/;
(I use regex here because HTML
here is odd)
Upvotes: 1