how can turn my results into hash from array into this
FT = { 'team' => 'score', 'team' => 'score', 'team' => 'score' };
PSTP = { 'team' => 'team', 'team' => 'team', 'team' => 'team' };
#!/usr/bin/perl use strict; use warnings; use Mojo::UserAgent; use Mojo::Util qw(dumper trim); use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); print "Content-type: text/html\n\n"; my $cgi = CGI->new; my $url = 'https://int.soccerway.com/matches/2020/12/28/'; my $ua = Mojo::UserAgent->new; my @results = $ua ->get( $url ) ->result ->dom ->find( 'table.matches_new tr.match' ) ->map( sub { my $row = $_; my @results = map { trim( $row->at( $_ )->all_text ) } qw( td.minute td.team-a td.score-time td.team-b ); return \@results; } ) ->to_array; print dumper( @results );
Original content, restored by gods:
the code is running and working but i want to archive this:
i want to find a team and its scores after word FT left and right side teams
the problem i have even my little Try am still getting error: cant find team even if the team is on list
#!/usr/bin/perl use strict; use warnings; use CGI; use HTML::TableExtract; use LWP::UserAgent; my $cgi = CGI->new; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => "https://int.soccerway.com/matches +/2020/12/28/"); my $res = $ua->request($req); my $html = $res->decoded_content; $html =~ s/<span.*?<\/span>//gs; $html =~ s/<script.*?<\/script>//gs; $html =~ s/<td(?=[^>]*class="events-button button first-occur")[^>]*>/ +/gs; my $table = HTML::TableExtract->new(); $table->parse($html); my $input = $cgi->param("team"); my $response =''; print "Content-type: text/html\n\n"; foreach my $row ($table->rows) { my $output = join("", @$row); $output =~ s/\R//g; print $output; if ($input) { # Find matching team (Its a must to find team after word FT) if ($output =~ m/$input/) { # After that team the next is score (Gets team scores - left sid +e) # Or after scores what team is near (Gets team scores - Right si +de) my $score = $output =~ /$input\s*?(\S+)/; $response ="Found Team And Score is: $score"; } else { $response ="Can't find team"; } } } print <<EOF; <!DOCTYPE html> <html> <body> <h1>Test</h1> <form method="post"> <label for="team">Enter Team:</label> <input type="text" name="team"><br><br> <input type="submit" value="Check"> </form> <h4>$response</h4> </body> </html> EOF
In reply to sorting out HTTP results by bigup401
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |