udaybhaskar has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use diagnostics; use strict; use LWP; use Date::Manip; use HTTP::Cookies; use URI; my $cookie_jar; $cookie_jar = HTTP::Cookies->new( 'file' => 'cookies.lwp', 'autosave' => 1, ); my $url = URI->new ('http://www.nseindia.com/marketinfo/indices/indexwatch.jsp'); my $browser = LWP::UserAgent->new(timeout=>'45', agent=>'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) G +ecko/20101012 Firefox/3.6.11'); $browser->cookie_jar($cookie_jar); push @{ $browser->requests_redirectable }, 'POST'; my $html_page; my $response = $browser->get($url); if ($response->is_error()) { print "error in getting index ".$response->status_line()."\n"; print "try again...\n"; } else { $html_page = $response->content(); if ($html_page =~ m{<a href=#top>Top</a></center>}) { print "got Index\n"; } elsif ($html_page =~ m/Your request could not be processed/) { print "\t\t\tNSE is down. Trying again...\n\n"; } else { print "$html_page\n"; print "failed to get index. Trying again...\n"; } }
This code worked till yesterday. However today I am hitting the 403 error.
I used the same UserAgent as that of Mozilla which successfully retrieves the page. I tried it from different IP address to ensure that my IP is not blocked(I run it once a day and am not running a bot) Looking for some help in getting this going again. Thanks Udayerror in getting index 403 Forbidden try again...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sudden problems with LWP::UserAgent
by Corion (Patriarch) on Oct 27, 2010 at 07:08 UTC | |
by udaybhaskar (Initiate) on Oct 27, 2010 at 08:04 UTC | |
by Corion (Patriarch) on Oct 27, 2010 at 08:11 UTC | |
by Argel (Prior) on Oct 27, 2010 at 22:24 UTC | |
by udaybhaskar (Initiate) on Oct 28, 2010 at 08:00 UTC | |
|
Re: Sudden problems with LWP::UserAgent
by morgon (Priest) on Oct 27, 2010 at 14:35 UTC | |
by udaybhaskar (Initiate) on Oct 28, 2010 at 05:46 UTC | |
by udaybhaskar (Initiate) on Nov 01, 2010 at 10:26 UTC | |
by Anonymous Monk on Apr 09, 2011 at 11:54 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |