Skip to content

Instantly share code, notes, and snippets.

@latk latk/
Created Sep 17, 2013

What would you like to do?
SO: 18826446 helper script
use strict; use warnings;
use feature 'say';
use autodie;
use File::Slurp;
use Mojo;
use List::MoreUtils 'uniq';
use Data::Dump qw/dd pp/;
my %urls = (
"local mirror 1" => 'original URL redacted',
"local mirror 2" => 'original URL redacted',
for my $file (sort keys %urls) {
my $dom = Mojo::DOM->new(scalar read_file $file);
say "I looked at the source of the page at `$urls{$file}`, and the form has following `<input>`s:";
say "";
for my $input ($dom->find('form input')->each) {
delete @{ $input->attr }{qw/height id class/};
say " * `", $input->to_xml, "`";
say "";
say "And the following `<select>` groups:";
say "";
for my $select ($dom->find('form select')->each) {
delete @{$select->attr}{qw/id style width size/};
my $options = pp sort { do{no warnings 'numeric'; $a <=> $b} } grep length(), $select->find('option')->attr("value")->each;
say " * `", $select->to_xml, "` with values ",
join ", ", map "`$_`", $options;
say "";
my @links = uniq map s/^[^?]*//r, grep /poll_data\.pl?/, $dom->find('a')->attr("href")->each;
if (@links) {
say "Additionally, links with the following queries are present:";
say "";
say " * `$_`" for @links;
say "";
say "which means that the script also responds to GET requests";
say "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.