Google CSE - jak zrobyć wyszukiwarkę "o Pythonie" :)
21 September 2008
Comments
Google udostępnia usługę Custom Search Engine - CSE umożliwiającą skonfigurowanie wyszukiwarki Google tak, by zwracała bardziej dopasowane wyniki do naszych założeń. Usługa zbyt popularna nie jest (do przeszukiwania własnej strony używamy np. Google Ajax search) i jest dość złożona, lecz umożliwia znaczącą konfigurację zwracanych wyników.
Przykładowo gdy chcemy mieć wyszukiwarkę szukająca informacji o Pythonowych frameworkach to wyniki dotyczące Rainharda Django czy pylonów konstrukcyjnych (pylons) nie są tym czego chcemy...
Oto prosty plik XML konfigurujący wyszukiwarkę CSE:<?xml version="1.0" encoding="UTF-8" ?>
<GoogleCustomizations>
<CustomSearchEngine>
<Title>Python-Search</Title>
<Description>Python-Search</Description>
<Context>
<BackgroundLabels>
<Label name="pylabel" mode="BOOST" weight="0.8" />
</BackgroundLabels>
</Context>
</CustomSearchEngine>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=python+$q&btnG=Search&num=100&label=pylabel"/>
<Annotations>
<Annotation about="http://wiki.pylonshq.com/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://pylonshq.com/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://www.djangoproject.com/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://code.djangoproject.com/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://www.djangobook.com/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://docs.python.org/lib/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://docs.python.org/dev/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/*">
<Label name="pylabel"/>
</Annotation>
</Annotations>
</GoogleCustomizations>
<BackgroundLabels>
<Label name="pylabel" mode="BOOST" weight="0.8" />
</BackgroundLabels>

<?xml version="1.0" encoding="UTF-8" ?>
<GoogleCustomizations>
<CustomSearchEngine>
<Title>Python-Search</Title>
<Description>Python-Search</Description>
<Context>
<BackgroundLabels>
<Label name="pylabel" mode="BOOST" weight="0.8" />
</BackgroundLabels>
<Synonyms>
<SynonymEntry word="pylons">
<Synonym>pylons framework</Synonym>
</SynonymEntry>
<SynonymEntry word="pylons">
<Synonym>pylons python</Synonym>
</SynonymEntry>
</Synonyms>
</Context>
<Context refinementsTitle="Search for $q in categories:">
<Facet>
<FacetItem title="Python">
<Label name="pylabel" mode="BOOST" weight="0.8">
<IgnoreBackgroundLabels>true</IgnoreBackgroundLabels>
</Label>
</FacetItem>
</Facet>
<Facet>
<FacetItem title="Pylons">
<Label name="pylons" mode="FILTER">
<IgnoreBackgroundLabels>true</IgnoreBackgroundLabels>
</Label>
</FacetItem>
</Facet>
<Facet>
<FacetItem title="Django">
<Label name="django" mode="FILTER">
<IgnoreBackgroundLabels>true</IgnoreBackgroundLabels>
</Label>
</FacetItem>
</Facet>
<Facet>
<FacetItem title="Python Reference">
<Label name="pyreference" mode="FILTER">
<IgnoreBackgroundLabels>true</IgnoreBackgroundLabels>
</Label>
</FacetItem>
</Facet>
</Context>
</CustomSearchEngine>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=python+language&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=jython&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=ironpython&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=django+framework&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pylons+framework&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pyqt&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pygtk&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=python+$q&btnG=Search&num=100&label=pylabel"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pylons+framework&btnG=Search&num=100&label=pylons"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pylons+python&btnG=Search&num=100&label=pylons"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pylons+python+$q&btnG=Search&num=100&label=pylons"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=pylons+framework+$q&btnG=Search&num=100&label=pylons"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=django+framework&btnG=Search&num=100&label=django"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=django+python&btnG=Search&num=100&label=django"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=django+framework+$q&btnG=Search&num=100&label=django"/>
<Include type="Annotations" href="http://www.google.com/cse/tools/makecse?url=http://www.google.com/search?q=django+python+$q&btnG=Search&num=100&label=django"/>
<Annotations>
<Annotation about="http://docs.python.org/lib/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://docs.python.org/dev/*">
<Label name="pylabel"/>
</Annotation>
<Annotation about="http://wiki.pylonshq.com/*">
<Label name="pylons"/>
</Annotation>
<Annotation about="http://pylonshq.com/*">
<Label name="pylons"/>
</Annotation>
<Annotation about="http://docs.djangoproject.com/en/dev/*">
<Label name="django"/>
</Annotation>
<Annotation about="http://code.djangoproject.com/wiki/*">
<Label name="django"/>
</Annotation>
<Annotation about="http://www.djangobook.com/*">
<Label name="django"/>
</Annotation>
<Annotation about="http://docs.python.org/lib/*">
<Label name="pyreference"/>
</Annotation>
<Annotation about="http://docs.python.org/dev/*">
<Label name="pyreference"/>
</Annotation>
</Annotations>
</GoogleCustomizations>


RkBlog
Comment article