Group
Extension

Web-oEmbed/tools/fetch-providers.pl

#!/usr/bin/perl
use strict;
use JSON::XS;
use Web::Scraper;
use URI;

sub extract_url { (m!(http://\S*)!)[0] }

my $uri = URI->new( shift || "http://www.oembed.com/" );

my $scraper = scraper {
    process "//h3[contains(text(), 'Providers')]/following-sibling::ul", 'providers[]' => scraper {
        process "//li[contains(text(), 'URL scheme')]", url => [ 'TEXT', \&extract_url ];
        process "//li[contains(text(), 'endpoint') or contains(text(), 'Endpoint')]", api => [ 'TEXT', \&extract_url ];
    };
    result 'providers';
};

my @providers = grep { defined $_->{url} } @{ $scraper->scrape($uri) };
print encode_json(\@providers);





Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.