Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have got this script to automate submitting a form to a website and getting the response back.
only this site is powered by .net and when I use user agent to get even the home page it is allways getting an
error and redirecting to an error page asperrorpath=...

I found out the if I turn of the cookies I get this message all the time - meaning that the site is storing id
and session on my computer as a cookie.

so I added the cookie functionality to the user agent but I can't seem to have the site store the
cookies on any cookie folder not the cutom lwp_cookies (see script)
and not he default microsoft cookie folder.

any suggestions???

use LWP::UserAgent; use HTTP::Request::Common qw(POST); use HTTP::Cookies; use HTTP::Cookies::Microsoft; BEGIN { $LWP::DebugFile::outname = 'c:/ua_debug.txt' } use LWP::DebugFile qw(+);
_____ tried that
#create cookies jar to hold the cookies for this user agent my $cookie_jar = HTTP::Cookies->new( file => "c:/MyFolder/Cookies/lwp_c +ookies.dat", autosave => 1, );
_____and also that
#create cookies jar to hold the cookies for this user agent my $cookie_jar = HTTP::Cookies::Microsoft->new( file => "c:/Documents and Settings/owner/Cookie +s/index.dat", 'delayload' => 0, ); my $ua; #user agent $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $curUrl =""; print "getting $curUrl\n"; @curContent = newGetRequest($curUrl); sub newGetRequest() { my $myUrl; my $myRes; my $myReq; # get url to create a request from $myUrl=@_[0]; # Create a request $myReq = HTTP::Request->new(GET =>"$myUrl"); #pass any cookies that exsists with this request $cookie_jar->add_cookie_header($myReq); # pass request to user agents $myRes = $ua->send_request($myReq); # if response put some cookies get them $myRes->base(""); $cookie_jar->extract_cookies($myRes); # get cookies put by the site if ($myRes->is_success) { print "Success in GET $myUrl" ; return $myRes->content; }else { print "Fail in GET $myUrl"; } }

Edit by thelenm: added code tags

In reply to Getting a Cookie from .net iis server by benny666

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-08-14 00:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found