I once needed to work with javascript. I just parsed the html and grepped for the variable initialization that I needed and took the value with a regex. No need to execute the code just to concatenate a couple of strings together.
As for the other part of your request regarding an https request, I've had mixed results. I have been unable to get https working through our proxy/firewall at work. I can go through the proxy via http without a problem. A bit of googling leads me to
a link dated 2001 that says libwww and crypt::ssleay almost work together but don't.
Here's a short example I've used to illustrate the problem. It fails for me on ActiveState 5.8.4 on xp. (*nix is not an option as this is my work machine, nor is cygwin)
#!/usr/bin/perl
use warnings;
use strict;
use LWP::UserAgent;
#http://groups.yahoo.com/group/libwww-perl/message/7242
$|=1;
my @hosts = ('http://login.yahoo.com', 'https://login.yahoo.com');
my $ua=LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 ");
my $https_proxy=$ENV{https_proxy};
delete $ENV{https_proxy} if ($https_proxy);
$ua->env_proxy;
$ENV{https_proxy}=$https_proxy if ($https_proxy);
foreach (@hosts) {
my $req = HTTP::Request->new(GET => $_);
#$req->proxy_authorization_basic($ENV{HTTP_PROXY_USER}, $ENV{HTTP_PR
+OXY_PASS});
my $res = $ua->request($req);
if ($res->is_success) { print $res->status_line, "\nsomething\n"; }
else { print $res->status_line, "\nnothing\n"; }
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.