Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello,

Greetings Monks,

Below is my code, dont know why it is not working.

use strict; use WWW::Mechanize; my $url = "http://www.truro-penwith.ac.uk/"; my $mech = WWW::Mechanize->new(); print "\nURL: $url ...\n"; eval{ $mech->agent_alias('Windows Mozilla'); #$mech->add_header('User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; WOW64; +rv:25.0) Gecko/20100101 Firefox/25.0'); #$mech->add_header('Accept'=>'text/html,application/xhtml+xml,applicat +ion/xml;q=0.9,*/*;q=0.8'); #$mech->add_header('Accept-Language'=>'en-US,en;q=0.5'); #$mech->add_header('Accept-Encoding'=>'gzip, deflate'); #$mech->add_header('Cookie'=>'bb2_screener_=1385998863+111.92.64.106; +PHPSESSID=078fc31740655a3a3f5fb280dbdf335d'); $mech->add_header('Connection'=>'keep-alive'); $mech->get($url); }; #$mech = $mech->content(); $mech = $mech->response->content(); print $mech; exit;

Anyone know what could be the proper reason.

Site is detecting this as a script, I tried adding headers with add_header & default_header, but nothing works. Response shows 400 Error and sometimes 403 Error. I wonder why this happened even though I had given the headers. Any ideas, I don't :(

Thanks in advance


In reply to Perl mechanize get Error! by Anonymous Monk

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-23 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found