Jump to content

Web scraping: Difference between revisions

→‎{{header|Raku}}: updated raku programming solution ( with a new data source )
m (→‎{{header|Phix}}: added libheader)
(→‎{{header|Raku}}: updated raku programming solution ( with a new data source ))
Line 1,693:
=={{header|Raku}}==
(formerly Perl 6)
<lang perl6># 20210301 Updated Raku programming solution
<lang perl6>use HTTP::Client; # https://github.com/supernovus/perl6-http-client/
 
<lang perl6>use HTTP::Client; # https://github.com/supernovus/perl6-http-client/
 
#`[ Site inaccessible since 2019 ?
my $site = "http://tycho.usno.navy.mil/cgi-bin/timer.pl";
HTTP::Client.new.get($site).content.match(/'<BR>'( .+? <ws> UTC )/)[0].say</lang>
# ]
 
my $site = "https://www.utctime.net/";
my $matched = HTTP::Client.new.get($site).content.match(
/'<td>UTC</td><td>'( .*Z )'</td>'/
)[0];
 
say $matched;
#$matched = '12321321:412312312 123';
with DateTime.new($matched.Str) {
say 'The fetch result seems to be of a valid time format.'
} else {
CATCH { put .^name, ': ', .Str }
}</lang>
 
Note that the string between '<' and '>' refers to regex tokens, so to match a literal '&lt;BR&gt;' you need to quote it, while <ws> refers to the built-in token whitespace.
Also, whitespace is ignored by default in Raku regexes.
{{out}}
<pre>
「2021-03-01T17:02:37Z」
The fetch result seems to be of a valid time format.
</pre>
 
=={{header|REBOL}}==
351

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.