Below is a script which makes a search plugin for arbitrary site.

It can create plugin not only for search engines but for any dynamic site which accepts CGI parameters.

To create search plugin:

  1. Make a search of bareword searchTerms, then copy a url appeared in address bar of a browser
  2. Run the script with that url as parameter
  3. Redirect script output to .xml file in searchplugins directory of your firefox profile

As an example let's create search plugin for LiveJournal

  1. Search 'searchTerms' using the search form
  2. Got url http://search.livejournal.ru/ljsearch?query=searchTerms&ie=utf-8
  3. run the script with url as parameter
    perl mksp.pl Livejournal 'http://search.livejournal.ru/ljsearch?query= +searchTerms&ie=utf-8' > ~/.mozilla/firefox/ze02d000.default/searchplu +gins/lj.xml
  4. restart FireFox and enjoy with blue pen of LiveJournal in search plugins
#!/usr/bin/perl -- use strict; use LWP::Simple; use MIME::Base64 qw(encode_base64); die "Usage: $0 Name 'SearchURLString'\n" if @ARGV < 2; my ($name, $url) = @ARGV; my ($site) = split '(?<![:/])/', $url; my $ico = get($site . '/favicon.ico'); unless ($ico) { $site =~ s{http://[^.]+\.}{http://}; $ico = get($site . '/favicon.ico'); } die "Can't get favicon for $site\n" unless defined $ico; my $base64 = encode_base64($ico); $url =~ s/searchTerms/{searchTerms}/gi; $url =~ s/&(?!amp;)/&amp;/g; print <<END_OF_SEARCHPLUGIN; <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/"> <os:ShortName>$name</os:ShortName> <os:Description>$name</os:Description> <os:InputEncoding>UTF-8</os:InputEncoding> <os:Image width="16" height="16"> data:image/x-icon;base64,$base64</os:Image> <SearchForm>$site</SearchForm> <os:Url type="text/html" method="GET" template="$url"> </os:Url> </SearchPlugin> END_OF_SEARCHPLUGIN __END__

In reply to Create FireFox search plugin for arbitrary web site by ccn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.