I looked through what you posted on my questions, and we were looking at this in April and May of this year, and I was very keen to know where the sun was going to be then. Many of the scripts I wrote then were mishmashes: I was experimenting, and it would all ultimately not get off the ground on my shared server.
Then we had the perl conference, my first, and I realized everything had to change because everything had changed.
$ pwd /home/hogan/mojo $ ls 1.button.pl 5.3.elev.debug.pl 5.3.elev.pl $
Q1) How do grown-ups configure their mojo capability on their development machine? Is it, like me right, a single directory that will eventually have dozens of files with names that look almost the same. The way I can guess which one works is what has the highest number. But this can also be where I gave up the ghost on a string of bad ideas expressed in script.
Q2) Since I have perlbrew on the remote server (recommended by mojo), should I install it on the laptop, i.e. the development machine?
Let's tack to what parts work. Output, then source.
2020/12/11 10:45:52 INFO ./3.mojo_fermi.pl 2020/12/11 10:45:53 INFO i is 0 ============== 2020/12/11 10:45:53 INFO <?xml version="1.0" encoding="iso-8859-1"?> 2020/12/11 10:45:53 INFO i is 1 ============== 2020/12/11 10:45:53 INFO 2020/12/11 10:45:53 INFO i is 2 ============== 2020/12/11 10:45:53 INFO <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 +Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2020/12/11 10:45:53 INFO i is 3 ============== 2020/12/11 10:45:53 INFO 2020/12/11 10:45:53 INFO i is 4 ============== 2020/12/11 10:45:53 INFO <html lang="en" xml:lang="en" xmlns="http://w +ww.w3.org/1999/xhtml"> <head> <title> Sky above 45°31'5"N 122°40'33"W at Fri 2020 Dec 11 1 +8:45 </title> </head> <body> snip <p /> <a href="/yoursky/help/ephemeris.html"><b>Ephemeris:</b></a><center> <table border="border" cellpadding="3"> <tr><th rowspan="2"> </th><th rowspan="2">Right<br />Ascension</th><th + rowspan="2">Declination</th><th rowspan="2">Distance<br />(<span tit +le="Astronomical units (149,597,871 km)">AU</span>)</th><th colspan=" +2">From 45°31'5"N 122°40'33"W:</th></tr> <tr><th>Altitude</th><th>Azimuth</th></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=0&z=1">Sun</a></th><td + align="right">17h 17m 17s</td><td align="right">−23° 4.4'< +/td><td align="right">0.985</td><td align="right">19.130</td><td alig +n="right">−19.052</td><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=1&z=1">Mercury</a></th +><td align="right">16h 56m 57s</td><td align="right">−23° 19.1& +#39;</td><td align="right">1.438</td><td align="right">19.910</td><td + align="right">−14.157</td><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=2&z=1">Venus</a></th>< +td align="right">15h 32m 32s</td><td align="right">−17° 41.8 +9;</td><td align="right">1.480</td><td align="right">26.501</td><td a +lign="right">7.028</td><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=3&z=1">Moon</a></th><t +d align="right">14h 35m 51s</td><td align="right">−11° 41.4' +;</td><td align="right">57.0 <span title="Earth radii (6378.14 km)">E +R</span></td><td align="right">29.801</td><td align="right">23.591</t +d><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=4&z=1">Mars</a></th><t +d align="right">1h 12m 37s</td><td align="right">+8° 4.4'</td><td + align="right">0.725</td><td align="right">−24.754</td><td alig +n="right">−133.649</td><td>Set</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=5&z=1">Jupiter</a></th +><td align="right">20h 2m 11s</td><td align="right">−20° 57.3&# +39;</td><td align="right">5.841</td><td align="right">3.667</td><td a +lign="right">−54.781</td><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=6&z=1">Saturn</a></th> +<td align="right">20h 6m 43s</td><td align="right">−20° 37.7 +9;</td><td align="right">10.733</td><td align="right">3.271</td><td a +lign="right">−55.819</td><td>Up</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=7&z=1">Uranus</a></th> +<td align="right">2h 20m 0s</td><td align="right">+13° 28.6'</td> +<td align="right">19.043</td><td align="right">−26.910</td><td +align="right">−152.851</td><td>Set</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=8&z=1">Neptune</a></th +><td align="right">23h 18m 20s</td><td align="right">−5° 39.9&# +39;</td><td align="right">29.945</td><td align="right">−17.891< +/td><td align="right">−100.409</td><td>Set</td></tr> <tr><th><a href="/cgi-bin/uncgi/Yourtel?aim=9&z=1">Pluto</a></th>< +td align="right">19h 41m 19s</td><td align="right">−22° 34.9 +9;</td><td align="right">34.999</td><td align="right">5.255</td><td a +lign="right">−49.911</td><td>Up</td></tr> </table> </center> <blockquote> snip </body> </html> 2020/12/11 10:45:53 INFO i is 5 ============== 2020/12/11 10:45:53 INFO
Source:
#!/usr/bin/perl use strict; use warnings; use Mojo::URL; use Mojo::Util qw(dumper); use Mojo::UserAgent; use Data::Dump; use Log::Log4perl; use 5.016; use Mojo::DOM; my $log_conf3 = "/home/hogan/Documents/hogan/logs/conf_files/3.conf"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/4.conf"; #Log::Log4perl::init($log_conf3); #debug Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); my $site = 'https://www.fourmilab.ch/cgi-bin/Yoursky?z=1&lat=45.5183&ns=North&lon +=122.676&ew=West'; # pretend to be a browser my $uaname = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like G +ecko) Chrome/40.0.2214.93 Safari/537.36'; my $ua = Mojo::UserAgent->new; $ua->max_redirects(5)->connect_timeout(20)->request_timeout(20); $ua->transactor->name($uaname); # find search results my $dom = $ua->get($site)->res->dom; # dd $dom; #overwhelms STDOUT say "==========="; my @nodes = @$dom; # c-style for is good for array output with index for ( my $i = 0 ; $i < @nodes ; $i++ ) { $logger->info("i is $i =============="); $logger->info("$nodes[$i]"); } sleep 2; #good hygiene __END__
The ephemeris is when i=4 here. That's where we are gonna be fishing for values.
The mojo syntax for tables is...idiomatic, but you gave me an example in Re: polishing up a json fetching script for weather data. Excerpting your response:
say 'Julian Day: ' . $dt->jd; my $pturl = 'http://www.fourmilab.ch/cgi-bin/Yoursky?z=1&lat=45.5183& +ns=North&lon=122.676&ew=West'; # you wanted Julian date so it looks like date should be '2' from the +source. my $tx = $ua->post( $pturl => form => { utc => $dt->jd, date => '2' } +); my $sunrow = $tx->res->dom->at('center:nth-of-type(3) table tr:nth-of- +type(3)'); # output say 'Name:' . $sunrow->children->[0]->all_text; say 'Altitude: ' . $sunrow->children->[4]->text; say 'Azimuth: ' . $sunrow->children->[5]->text; say 'Visible: ' . $sunrow->children->[6]->text;
So now I need to adapt this for Saturn and Jupiter, but I don't want to hard code that part this time: they should be selected. I think I can get this done with 2 sets of radio buttons, if a pull-down menu is more than I want to bite off at this point. So that's where I am tonight.
I haven't started coding anew, wanting to rather begin with a reasonable write-up. Thanks for your comments,
In reply to Re^2: calculating planet conjunction with mojo front end
by Aldebaran
in thread calculating planet conjunction with mojo front end
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |