I have a task to read the view source of a Share Point site and pick the email address from the view source.
I have tried as I do usually using get, UserAgent, robot etc.. But I couldn't anything other than 401 unauthorized Error.
I have tried passing the cridentials through header method of HTTPRequest, credentials method of UserAgent still my problem didn't get solved.
Here are the code snippets which I have tried in different ways. It would be great, if you someone help me on this. Thanks in Advance.
#!/usr/bin/perl -w use strict; use URI::Escape; use LWP::Simple; use LWP 5.64; use LWP::UserAgent; use LWP::RobotUA; require HTTP::Request; my $url_template = "<sharepoint website>"; # SOrry I cann't provi +de site name becoz itz our compnay interenal site. which I cann't dis +close my $ua = LWP::UserAgent->new; $ua->credentials('<sharepoint website>:80', '', '<userid>', '<pass +word>'); my $request = HTTP::Request->new(GET => "$url_template"); my $response = $ua->request($request) or print "Failed to send req +uest: $!"; # error check $content = $response->content(); # document OK #$response->is_success() || warn $response->message(); if ($response->is_success) { print $response->content; } else { print "Error: " . $response->status_line . "\n"; } or my $request = HTTP::Request->new(GET => "$url_template"); $request->content_type('text/html'); $request->authorization_basic('<userid>', '<password>'); #$request->header( $field => $value ) #my $response = $ua->get($url_template); my $response = $ua->request($request); if ($response->is_success) { $content = $response->decoded_content; # or whatever print $content; } else { die $response->status_line; } or # create robot my $robot = LWP::RobotUA->new('Mozilla/5.0 (Windows XP; U) Opera 6 +.0 [en]', '<emailid>'); # temporarily set delay to 0 minutes instaed of 10 $robot ->delay(0); my $request = HTTP::Request->new('GET', $url_template); # carry out network access my $response = $robot->request($request);
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |