Hi

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);

In reply to Unable to Access Share Point Site using Perl- 401 Unauthorized Error by suneel4u4ever

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.