develooper Front page | perl.libwww | Postings from February 2001

UserAgent with ASP

From:
Michael R. Fahey
Date:
February 14, 2001 00:05
Subject:
UserAgent with ASP
Message ID:
000101c0965c$975d36c0$912a230a@qilinlaw.com



The server returns an error when I request the following url using
LWP::UserAgent.


$url = 'http://someagency.gov.tw/reg/asp/WB0104I_1.asp?ScrollAction=Page 2';
$request = new HTTP::Request('GET', $url);

I can retrieve the first page with:

	$SEARCH_URL = 'http://someagency.gov.tw/reg/asp/WB0104I_1.asp';

	use LWP::UserAgent;
	use HTTP::Cookies;

	use CGI;
	$cgi = new CGI;
	$ua = new LWP::UserAgent;


	my $string_head = shift (@ARGV);
	my $file_name = "$string_head.html";

	open (OUT, "> $file_name") or die "Couldn't open $file_name for reading:
$!\n";

	$request = new HTTP::Request('POST', $SEARCH_URL);
	$request->content_type('application/x-www-form-urlencoded');
	$request->content("english_name=$string_head&basic_select=3&query=¬d¸ß");
#garbage characters here are Chinese (big-5) for 'query'
	$response = $ua->request( $request );


Then I want to get the next five pages, so I tried ...

	$url = 'http://someagency.gov.tw/reg/asp/WB0104I_1.asp?ScrollAction=Page
2';
	$request = new HTTP::Request('GET', $url);      $request->content();
	$response = $ua->request( $request );
	$content=$response->content();
	my $file_name = "$string_head2.html";open (OUT, "> $file_name") or die
"Couldn't open 	$file_name for reading: $!\n";
	print OUT $content;
	print "$content\n\n";

But no luck.  Is my url malformed? Does it need to be escaped?  It appears
in the browser as
http://someagency.gov.tw/reg/asp/WB0104I_1.asp?ScrollAction=Page%202 when I
go to the second page manually.

Thanks for any suggestions.

Michael Fahey




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About