The url ending pgs.php requires the query_string data to be looked up. The
url ending in “/“ is for the interactive page for a browser, say. You
shouldn’t have to specify “:443” (from your 500 error) instead just use
“https://“ prefix. In general http connections forward themselves to https;
if I go to nationalmap.gov I get forwarded to
https://www.usgs.gov/core-science-systems/national-geospatial-program/national-map

I don’t think env vars will help.


On Wed, Aug 28, 2019 at 5:03 PM Mike <te...@mflan.com> wrote:

>
> Thank you.  That helps me a lot to know that it works for you.
>
> Your code, exactly as you sent it, still does not work for me.
> It gives:
> 500 Can't connect to nationalmap.gov:443 (Bad address) at trash.pl line
> 19.
>
> I'm going to try to assign an environment variable to my
> system.  I doubt that will fix it, but I am trying just
> about everything.
>
> I still can't figure out why it works on some URL's,
> and not others.  It's probably going to take me a
> long time to figure this out.
>
>
> Mike
>
>
>
> On 8/28/2019 6:26 PM, $Bill wrote:
> > This seems fine on my Win10:
> >
> > use strict;
> > use warnings;
> > use LWP::UserAgent;
> >
> > my $url;
> > if (0) {    # set to 1 or 0 to flop urls
> >     $url = 'https://nationalmap.gov/epqs';
> > } else {
> >     $url =
> > '
> https://nationalmap.gov/epqs/pqs.php?y=34.0&x=-118.0&units=Feet&output=xml
> ';
> > }
> > my $ua = LWP::UserAgent->new(); #  ssl_opts => { verify_hostname => 0,
> > } );
> > $ua->agent("Mozilla/5.0 (Windows)");
> > my $response = $ua->get($url);
> > if ($response->is_success) {
> >     print $response->content;
> > } else {
> >     die $response->status_line;
> > }
> > print "All done.\n\n";
> >
> > __END__
> >
> > Dumps the page or elevation depending on url:
> >
> > perl test.pl
> > <?xml version="1.0" encoding="utf-8"
> > ?><USGS_Elevation_Point_Query_Service><Elevation_Query x="-118.0"
> > y="34.0"><Data_Source>3DEP 1/3
> >
> arc-second</Data_Source><Elevation>916.71</Elevation><Units>Feet</Units></Elevation_Query></USGS_Elevation_Point_Query_Service>All
>
> > done.
> >
> >
> >
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
> --
Andy Bach
afb...@gmail.com
Not at my desk

Reply via email to