Du befindest dich hier: FSI Informatik » Informationen » linuxkurs » Aufgabensammlung » Mensaskript (Übersicht)
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Nächste Überarbeitung | Vorherige Überarbeitung | ||
informationen:linuxkurs:aufgabensammlung:mensa [26.08.2016 06:27] – vorkurs => linuxkurs tomabrafix | informationen:linuxkurs:aufgabensammlung:mensa [10.11.2022 13:44] (aktuell) – Xinthra | ||
---|---|---|---|
Zeile 3: | Zeile 3: | ||
< | < | ||
- | #! / | + | # |
+ | use v5.12; | ||
use strict; | use strict; | ||
- | use integer; | + | use warnings; |
- | use Term:: | + | use utf8; |
- | use Date::Format; | + | use open qw( :std :locale |
- | my $time = time; | + | |
- | if ($#ARGV >= 0) { | + | |
- | $time += $ARGV[0] * 86400; | + | |
- | } | + | |
- | my $date = time2str(" | + | |
- | my @pars = split(/\n\s*\n/m, `w3m -dump http:// | + | use HTML:: |
+ | use WWW::Mechanize (); | ||
- | my @result | + | my $URL = 'http://www.werkswelt.de/? |
- | $, = "\n\n"; | + | my @color |
+ | my $color_reset = "\e[m"; | ||
- | print @result; | + | sub get_food { |
- | print " | + | my $idx = shift; |
+ | my ($html) = @_; | ||
+ | foreach my $line (split /\n/, $html) { | ||
+ | next unless $line =~ / | ||
+ | |||
+ | $line =~ m{< | ||
+ | say " | ||
+ | |||
+ | while ($line =~ m{(Essen \d+)</ | ||
+ | my $food = $1; | ||
+ | my $name = $2; | ||
+ | |||
+ | $name =~ s{< | ||
+ | $name =~ s{\([\d\w, | ||
+ | $name =~ s{\s+}{ }g; | ||
+ | say " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | my $mech = WWW:: | ||
+ | |||
+ | $mech-> | ||
+ | get_food(0, | ||
+ | |||
+ | for (my $i = 0; $i < 2; $i++) { | ||
+ | my $next = $mech-> | ||
+ | $mech-> | ||
+ | get_food($i+1, | ||
+ | } | ||
</ | </ | ||
- | Dieses // | + | Dieses // |
Sinnvollerweise sollte das Script als '' | Sinnvollerweise sollte das Script als '' |