diff options
author | David <dbphillipsnz@gmail.com> | 2014-11-24 14:22:54 +1300 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-11-24 14:22:54 +1300 |
commit | d9613adba28e7c4dea982f81912c80fe1294adb4 (patch) | |
tree | 5baab5e51e015c45d8b6eddc611ade6c18e1ffc1 | |
parent | 77035f32e5c2912505a9958aa426d34e6139478f (diff) | |
download | svgcaptcha-parser-d9613adba28e7c4dea982f81912c80fe1294adb4.tar.xz |
It works!
-rwxr-xr-x | svgcaptcha-parser | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/svgcaptcha-parser b/svgcaptcha-parser new file mode 100755 index 0000000..af98720 --- /dev/null +++ b/svgcaptcha-parser @@ -0,0 +1,26 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use XML::Simple; + + +# Fetch fresh svg and parse it +die("Failed to download new svg: $!\n") unless my $raw_svg = `curl -s http://svgcaptcha.com/captcha.php`; + +my $svg = XMLin($raw_svg, KeyAttr => {"text", "x"})->{"text"}; + + +# Build the filename +my $filename = ""; +foreach my $i (sort {$a <=> $b} keys %$svg) +{ + $filename .= %$svg{$i}->{"content"}; +} + +# Write to file +open(my $f, ">", "$filename.svg") or die("Failed to open $filename.svg: $!\n"); +print($f $raw_svg) or die("Failed to write to file: $!\n"); +print("Saved $filename.svg\n"); +close($f); |