perl - How to pass through redirect page by clicking button in html -


i create perl scripts information website. webpage not redirect , need click continue myself redirect it. can using perl?

#!/usr/bin/perl -w  use feature ':5.10'; use strict; use warnings; use lwp::useragent; use http::request; use http::request::common qw(post); use http::cookies; use cacertorg::ca; $env{perl_lwp_ssl_verify_hostname} = 0;   $outfile="out.html"; $url="http://www.example.com; $ua = lwp::useragent->new(); $ua->ssl_opts(     ssl_verify_mode   => 'ssl_verify_none',     verify_hostnames => 0,     ssl_ca_file      => cacertorg::ca::ssl_ca_file() ); $ua->cookie_jar(http::cookies->new(file => 'cookie_jar', autosave =>1));   $req =http::request::common::post("$url",    content_type=>'form-data',    content =>[          'username'=>'user',          'password'=>'pass',          'vhost'=>'standard'   ] ); $req->header('cookie' =>q(tin=287000; lastmrh_session=439960f5; mrhsession=78c9c47291c1fcedae166121439960f5));    $resp=$ua->request($req); open(outfile, ">$outfile"); print outfile $resp->decoded_content; close(outfile); 

the out.html print out

enter image description here

when open html file, directly redirect page want not in code. anywhere in code reach wwww.example.com.

added 8/18

i try using command , open www.example.com in browser

 $ret = system( 'out.html' ); 

but want html of www.example.com instead of open website.

the best solution to set location header. if option write output directly response (instead of output html file) can write headers before html content.

use http::headers; $headers = http::headers->new; $headers->header('content-type' => 'text/html'); $headers->header('location' => 'newaddr.html'); $headers->header('cookie' => q(tin=287000; lastmrh_session=439960f5; mrhsession=78c9c47291c1fcedae166121439960f5)); print $headers->as_string(); 

you can set http status code 302 temporary redirect if want.

alternatively use javascript automatically redirect after page has loaded adding html content.

<script type="text/javacript">     window.location = "newaddr.html"; </script> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -