Big day for perl and you, Util; I thought your presentation was awesome, but I could not ask any questions, as the only way I could hear anything was going to the livestream with youtube.

Then I hauled out an older machine with a newer ubuntu and now can hear the zoom proceedings. Maybe others had similar problems or not...I could be quite smart and be the local dunce in such matters.

I've always been interested in the weather and trees of every variety. bliako has posted several examples recently that are fascinating, but I had forgotten about HTML::TreeBuilder, which I used to use quite frequently.

You made a good case for curl'ing once:

$ curl -o 1.weather.html 'https://www.wunderground.com/weather/us/or/p +ortland' % Total % Received % Xferd Average Speed Time Time Time + Current Dload Upload Total Spent Left + Speed 100 847k 0 847k 0 0 487k 0 --:--:-- 0:00:01 --:--: +-- 487k $

I find your script quite elegant and readable:

$ ./1.wund_wind.pl N5 $ cat 1.wund_wind.pl #!/usr/bin/env perl use 5.016; use HTML::TreeBuilder; my $tree = HTML::TreeBuilder->new_from_file('1.weather.html') or die; my $wind = $tree->look_down( _tag => 'div', class => qr/^condition-wind /, ); say $wind->as_trimmed_text( extra_chars => '\xA0' ); $

Q1) What other fields are worth looking at at wunderground?

Q2) Any idea what the KORPORTL966 part of this url signfies?

https://www.wunderground.com/hourly/us/or/portland/KORPORTL966

(This has nothing to do with the parent response.) Q3) Why can't I crack this with Mojo?

#!/usr/bin/env perl use Mojo::UserAgent; use 5.016; use warnings; # Fetch website my $uaname = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 ( +KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36'; my $ua = Mojo::UserAgent->new; my $res = $ua->get('1.weather.html')->result; # Visit all nodes recursively to extract more than just text for my $n ($res->dom->descendant_nodes->each) { # Text or CDATA node print $n->content; # Also include alternate text for images print $n->{alt} if $n->type eq 'tag' && $n->tag eq 'img'; }
$ ./1.mo_tree.pl Can't connect: Name or service not known at ./1.mo_tree.pl line 9. $

Thanks everybody for presentations on a successful first day. As if covid could keep perl down....


In reply to Re^2: creating a webpage to fetch/calculate weather data by Aldebaran
in thread creating a webpage to fetch/calculate weather data by Aldebaran

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.