Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Perl: Login using Mechanize module

866420Jun 3 2011 — edited Aug 29 2013
Hello,

I'm working on a application that return a status of a website. For example, when i provide a link 'http://www.oracle.com/partners/index.html' in the application, it scans each and every link inside it and it also scans links inside parent link, links inside the child link, links inside the sibling link, it goes on until it end. Now my problem is, I couldn't access the secure pages of the site, i.e. which needs authentication. I have the following code,

#! "C:\perl\bin\perl.exe"

use strict;
use warnings;
use WWW::Mechanize;
use HTTP::Cookies;
use HTTP::Request::Common;
use Crypt::SSLeay;

my $url = "http://www.oracle.com/partners/secure/engage-with-oracle/index.html";

my $mech = WWW::Mechanize->new();
$mech->proxy('http', 'http://www-proxy.us.oracle.com:80');
$ENV{HTTPS_PROXY} = 'http://www-proxy.us.oracle.com:80';

my $username = 'my_email';
my $password = 'my_password';

$mech->cookie_jar(HTTP::Cookies->new());
my $testva = $mech->get($url);

$mech->form_number(0);
$mech->field("ssousername",$username);
$mech->field("password",$password);
$mech->submit_form();

print $mech->status;
print $mech->content;

it throws a error "Can't call method "value" on an undefined value at C:/Perl/lib/WWW/Mechanize.pm line 1403.". I don't know what does it exactly means. I tried it with other links like twitter,

my $url = "http://twitter.com/";

$mech->form_number(0);
$mech->field("session[username_or_email]",$username);
$mech->field("session[password]",$password);
$mech->submit_form();

In this instance, it works fine and print the content and status.

Please help me out this!!
Thanks in Advance.

Regards,
Aravind.M.S

Edited by: 863417 on Jun 3, 2011 4:12 AM

Comments

Ian G Clough

Hi James,
If you make the office's location the identifying attribute for the office (delete the other attribute as it's no longer required) and then your rules can look like this:
Screenshot 2022-04-28 at 10.07.09.pngScreenshot 2022-04-28 at 10.10.07.pngI'm not sure how you might infer other details about the office unless those could be shared rules.
Best regards
Ian

James Woon - Monad

Thanks for that suggestion!
In this case, I have used 'the office location' as an example entity attribute that needs to be populated. But unfortunately, the actually attribute are dates. So maybe something like the office's opening date. We also do need to maintain the identifier (XYZ1, ABC2, etc.).
Therefore, don't think the proposed solution would work :(

Richard Napier

Hello James,
Personally I wouldn't use inclusions. I would use Decision Services. Then I can create two separate decision services, in separate Workspaces, give users permissions, use the Viewer role or the Author role to let people view or edit the Decision Services. Generally I have much more control over them.
image.pngimage.pngI would create references in the OPM project to each of the decision services
image.png
image.png
And create entities to support ABC, XYZ and then the master entity to contain both
image.png
Then I would merge the two entities into one and copy over the location to the master entity.
image.png
image.pngJust my two cents
Have a lovely day

James Woon - Monad

Ah... Decision Services! Sad to say we're on Private Cloud 20C. 
Yes, this is probably the best solution for anyone looking to solve this issue.
(I tried to mark this as answered but it seems I chose 'Discussion' instead of 'Question' for this post)
As always, appreciate your contributions to the community, Richard!

Richard Napier

Ah, I see. I was confused by you saying you had a test project in 21D. Happy to help, James. Whether it be a discussion or a question :)

1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 26 2013
Added on Jun 3 2011
2 comments
2,925 views