O SAPO disponibiliza um Open Search RSS do seu motor de pesquisa em http://services.sapo.pt/Metadata/Service/Search.
Para efectuar uma pesquisa pelo termo "sapo", por exemplo, basta aceder a http://services.sapo.pt/Search/RSS?q=sapo, recebendo-se uma resposta algo como:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:products="http://www.sapo.pt/RSS/Modules/Search/Products" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:sapo="http://www.sapo.pt/RSS/Modules/Search" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<link>http://pesquisa.sapo.pt/?q=sapo&rss=1</link>
<language>pt-pt</language>
<copyright>2008, PT.COM</copyright>
<description>sapo</description>
<title>sapo - Pesquisa SAPO</title>
<openSearch:totalResults>625000</openSearch:totalResults>
<openSearch:itemsPerPage>10</openSearch:itemsPerPage>
<openSearch:startIndex>0</openSearch:startIndex>
<item>
<link>http://adsl.sapo.pt/</link>
<title>SAPO ADSL</title>
<description>Banda Larga Móvel. Se já é Cliente SAPO ADSL, aproveite a Banda Larga Móvel Grátis!</description>
<guid>http://adsl.sapo.pt/</guid>
<author>crawlersapo <crawler@co.sapo.pt></author>
</item>
...
</channel>
</rss>
Para efectuar uma pesquisa pelos termos "software" e "livre", limitando o número de resultados a 5 e usando um offset de 10, por exemplo, basta aceder a http://services.sapo.pt/Search/RSS?q=software+livre&limit=5&offset=10.
Boas pesquisas!
use strict;
use warnings;
use XML::RSS::Parser;
my $rp = XML::RSS::Parser->new;
my $feed = $rp->parse_uri('http://services.sapo.pt/Search/RSS?q=sapo');
# Gather all the information on the feed results
my %info = ();
$info{'title'} = $feed->query('/channel/title')->text_content;
$info{'link'} = $feed->query('/channel/link')->text_content;
$info{'description'} = $feed->query('/channel/description')->text_content;
$info{'results'} = $feed->query('/channel/openSearch:totalResults')->text_content;
$info{'start_index'} = $feed->query('/channel/openSearch:startIndex')->text_content;
my @items = ();
foreach my $i ( $feed->query('//item') ) {
push @items, {
'title' => $i->query('title')->text_content,
'link' => $i->query('link')->text_content,
'description' => $i->query('description')->text_content,
}
}
# Display the information
print $info{'title'}, "\t", $info{'link'}, "\n",
$info{'description'}, "\n", "Número de resultados\t",
$info{'results'}, "\n", "Início\t", $info{'start_index'}, "\n";
foreach my $i (@items) {
print "-" x 80, "\n",
$i->{'title'}, "\n",
$i->{'link'}, "\n",
$i->{'description'},"\n";
}