W3C home > Mailing lists > Public > www-validator@w3.org > December 2002

[FYI] A usefull little snippet of Perl...

From: Terje Bless <link@pobox.com>
Date: Wed, 4 Dec 2002 21:53:16 +0100
To: W3C Validator <www-validator@w3.org>
Message-ID: <a01060007-1022-698135A607CA11D7987A00039300CF5C@[193.157.66.10]>

Since somebody asked about this in another forum I thought y'all might be
interested. The following is a little Perl snippet to post a file to the
Validator and, in this case, getting an XML report back.

Save this as e.g. "post.pl" and run it as "./post.pl file.html":

#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request::Common 'POST';

print LWP::UserAgent
  ->new
  ->request(
            POST 'http://validator.w3.org/check',
            Content_Type => 'form-data',
            Content      => [
                             output => 'xml',
                             uploaded_file => [$ARGV[0]],
                            ]
           )->as_string;
__END__


The "output" parameter can be adjusted to suit you ("xml", "earl", "n3") or
omitted alltogether to get the HTML report. Other interesting parameters
are "charset" (value is any charset we support (quite a few)) and "verbose"
("0" or "1") for verbose results in the HTML report only.


Note that this does not imply that the XML (or n3, or earl) interfaces are
any less beta then they were. It's just a usefull little snippet for
playing around with this.


-- 
Everytime I write a rhyme these people thinks its a crime
I tell `em what's on my mind. I guess I'm a CRIMINAL!
I don't gotta say a word I just flip `em the bird and keep goin,
I don't take shit from no one. I'm a CRIMINAL!
Received on Wednesday, 4 December 2002 15:53:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:05 GMT