Finding things on the web with BOSS

87
Finding things on the web with BOSS Christian Heilmann | http://wait-till-i.com | http://scriptingenabled.org Open Hack Day 2009 - Bangalore, India
  • date post

    19-Oct-2014
  • Category

    Technology

  • view

    6.047
  • download

    0

description

Introdcution to Yahoo's open search platform BOSS at Open Hack Day in Bangalore, India.

Transcript of Finding things on the web with BOSS

Page 1: Finding things on the web with BOSS

Finding things on the web with BOSS

Christian Heilmann | http://wait-till-i.com | http://scriptingenabled.org

Open Hack Day 2009 - Bangalore, India

Page 2: Finding things on the web with BOSS

What is innovation?

Page 3: Finding things on the web with BOSS

Innovation is improving the current state of affairs.

Page 4: Finding things on the web with BOSS

In the best of all cases this means that it gets easier for the person using a product

to reach a goal.

Page 5: Finding things on the web with BOSS

This can be achieved by connecting several different products and turning them into one. (pssst... Mashup).

Page 6: Finding things on the web with BOSS

I’ve seen this followed cleverly on several levels

here in India.

Page 7: Finding things on the web with BOSS
Page 8: Finding things on the web with BOSS

BOSS is your chance to make the web an easier to navigate

space.

Page 9: Finding things on the web with BOSS

You can help us turn a search engine into a find engine.

Page 11: Finding things on the web with BOSS

Back in the days the web was

small and largely static documents.

Page 12: Finding things on the web with BOSS

Nowadays it is huge and its content and the publication speed increased a lot.

Page 13: Finding things on the web with BOSS

This is one challenge of search engines these days.

Page 14: Finding things on the web with BOSS

The others are old, but also increasing

Page 15: Finding things on the web with BOSS

Now, say you have the most awesome idea of a search engine that works around these issues.

Page 16: Finding things on the web with BOSS

Where you will get stuck is the overhead of indexing,

storing and filtering the data of the web.

Page 17: Finding things on the web with BOSS

And this is where BOSS comes in.

Page 18: Finding things on the web with BOSS

It is an API interface to our data stores for search.

Page 19: Finding things on the web with BOSS

BOSS is Build Your Own Search Service:

http://developer.yahoo.com/search/boss/

Page 20: Finding things on the web with BOSS

To use it, you need a Application ID:

https://developer.yahoo.com/wsregapp/

Page 21: Finding things on the web with BOSS

And there is full documentation available:

http://developer.yahoo.com/search/boss/boss_guide/

Page 22: Finding things on the web with BOSS

Happy Hacking!

Page 23: Finding things on the web with BOSS

... oh alright then ...

Page 24: Finding things on the web with BOSS

You can get the code examples I will show here:

http://isithackday.com/hacks/bangalore/bosscode.zip

Page 25: Finding things on the web with BOSS

Say you want to search the web for donkeys.

Page 26: Finding things on the web with BOSS

... oh alright then ...

Because

Donkeys

Rock!

Page 27: Finding things on the web with BOSS

Using BOSS you can do this with a REST API and display

the results any way you want!

Page 29: Finding things on the web with BOSS

The REST API:boss.yahooapis.com/ysearch/{type}/v1/

{search}

type is what you want to search:

web: the interwebs

news: new stuff

images: pictures

Page 30: Finding things on the web with BOSS

The REST API:boss.yahooapis.com/ysearch/{type}/v1/

{search}

search is the term to look for (url-encoded)

Put “” around terms to ensure the right order, f.e. “donkey fur” (you don’t want to see cats, do you?)

Filter with a -, f.e. donkey -shrek

Restrict to a site using site:, f.e. donkey site:flickr.com

Page 31: Finding things on the web with BOSS

The REST API:boss.yahooapis.com/ysearch/{type}/v1/

{search}

Other parameters:appid: your app ID (needed)

count: amount of results

start: where to start the counting

region / lang: country and language

format: xml or json

sites: restrict to certain sites (comma separated)

Page 32: Finding things on the web with BOSS

Web search REST API:boss.yahooapis.com/ysearch/web/v1/{search}

Extra parameters:filter: To filter out nasties, use filter=-porn-hate

type: to search different types. You can use html, text, pdf, xl, msword, ppt or groups like msoffice and nonhtml. You can also do a type=msoffice,-xl

Page 33: Finding things on the web with BOSS

Image search REST API:boss.yahooapis.com/ysearch/images/v1/

{search}

Extra parameters:filter: no nudies

dimensions: all, small, medium, large, wallpaper, widewallpaper

refererurl: all images in that url

url: image at that url

Page 34: Finding things on the web with BOSS

News search REST API:boss.yahooapis.com/ysearch/news/v1/{search}

Extra parameters:age: how old the news are in days. Last five days would be “5d”

Page 35: Finding things on the web with BOSS

There are restrictions how to display results and

information as to what data comes back.

Page 36: Finding things on the web with BOSS

For this, read the guide!http://developer.yahoo.com/search/boss/boss_guide/

Page 37: Finding things on the web with BOSS

Everybody Duck!

Page 38: Finding things on the web with BOSS

There will be code

Page 39: Finding things on the web with BOSS

The easiest way to use BOSS is using JavaScript.

Page 41: Finding things on the web with BOSS

{"ysearchresponse":{"responsecode":"200","nextpage":"\/ysearch\/web\/v1\/donkeys?format=json&appid=[...]&start=10","totalhits":"492215","deephits":"15700000","count":"10","start":"0","resultset_web":[{"abstract":"Hyperlinked description of the domesticated mammal discussing its appearance, relationship to horses, economic <b>...<\/b> horses and <b>donkeys<\/b> were brought back <b>...<\/b>","clickurl":"http:\/\/lrd.yahooapis.com\/_ylc=X3oDMTU4b2NoaDR2BF9TAzIwMjMxNTI3MDIEYXBwaWQDVFg2YjRYSFYzNEVuUFhXMHNZRXI1MWhQMXBuNU84S0FHcy5MUVNYZXIxWjdSbW1WclpvdXo1U3Z5WGtXc1ZrLQRwb3MDMARzZXJ2aWNlA1lTZWFyY2hXZWIEc2xrA3RpdGxlBHNyY3B2aWQDR3lDaEgwU081cTlmSktUNG1ndTVUUUJNdlNjaS4wa1ZUVndBQVF5Sw--\/SIG=11820sato\/**http%3A\/\/en.wikipedia.org\

Page 42: Finding things on the web with BOSS

To use this across domains, simply define a callback

parameter:

Page 44: Finding things on the web with BOSS

founddonkeys({"ysearchresponse":{"responsecode":"200","nextpage":"\/ysearch\/web\/v1\/donkeys?format=json&callback=founddonkeys&appid=TX6b4XHV34EnPXW0sYEr51hP1pn5O8KAGs.LQSXer1Z7RmmVrZouz5SvyXkWsVk-&start=10","totalhits":"492215","deephits":"15700000","count":"10","start":"0","resultset_web":[{"abstract":"Hyperlinked description of the domesticated mammal discussing its appearance, relationship to horses, economic <b>...<\/b> horses and <b>donkeys<\/b> were brought back <b>...<\/b>","clickurl":"http:\/\/lrd.yahooapis.com\/_ylc=X3oDMTU4cG05cXJwBF9TAzIwMjMxNTI3MDIEYXBwaWQDVFg2YjRYSFYzNEVuUFhXMHNZRXI1MWhQMXBuNU84S0FHcy5MUVNYZXIxWjdSbW1WclpvdXo1U3Z5WGtXc1ZrLQRwb3MDMARzZX

Page 45: Finding things on the web with BOSS

All you then need to do is put this url in a script node and

write the founddonkeys function:

Page 46: Finding things on the web with BOSS

<div id="searchresults"></div> <script type="text/javascript"> function founddonkeys(o){ var donkeys = o.ysearchresponse.resultset_web; var results = document.createElement('ul'); for(var i=0,j=donkeys.length;i<j;i++){ var item = document.createElement('li'); var link = document.createElement('a'); var abstract = document.createElement('p'); link.setAttribute('href',donkeys[i].clickurl); link.innerHTML = donkeys[i].title; item.appendChild(link); abstract.innerHTML = donkeys[i].abstract; item.appendChild(abstract); results.appendChild(item); }

Page 48: Finding things on the web with BOSS
Page 49: Finding things on the web with BOSS

Two problems though:

Page 50: Finding things on the web with BOSS

First of all - without JavaScript there are no

donkeys!

Page 51: Finding things on the web with BOSS

Secondly - you can only find donkeys!

Page 52: Finding things on the web with BOSS

The solution: Event Handling and dynamic script

generation.

Page 53: Finding things on the web with BOSS
Page 54: Finding things on the web with BOSS

<p>Warning: this is terrible code, USE A LIBRARY INSTEAD!</p><ul id="searches"> <li><a href="http://search.yahoo.com/search?va=donkeys"> Search for Donkeys </a> </li> <li><a href="http://search.yahoo.com/search?va=kittens"> Search for kittens </a> </li></ul><div id="searchresults"></div>

Page 55: Finding things on the web with BOSS

<script type="text/javascript" charset="utf-8"> function founddonkeys(o){ var donkeys = o.ysearchresponse.resultset_web; var results = document.createElement('ul'); for(var i=0,j=donkeys.length;i<j;i++){ var item = document.createElement('li'); var link = document.createElement('a'); var abstract = document.createElement('p'); link.setAttribute('href',donkeys[i].clickurl); link.innerHTML = donkeys[i].title; item.appendChild(link); abstract.innerHTML = donkeys[i].abstract; item.appendChild(abstract); results.appendChild(item); } var resultsbox = document.getElementById('searchresults'); resultsbox.innerHTML = ''; resultsbox.appendChild(results); } var APIkey = 'TX6b4XHV34EnPXW0sYEr51hP1pn5O8KAGs'+ '.LQSXer1Z7RmmVrZouz5SvyXkWsVk-'; var searchlinks = document.getElementById('searches').getElementsByTagName('a'); for(var i=0;searchlinks[i];i++){

Page 56: Finding things on the web with BOSS

var APIkey = 'TX6b4XHV34EnPXW0sYEr51hP1pn5O8KAGs'+ '.LQSXer1Z7RmmVrZouz5SvyXkWsVk-'; var searchlinks = document.getElementById('searches').

getElementsByTagName('a'); for(var i=0;searchlinks[i];i++){ searchlinks[i].onclick = function(){ var searchterm = this.href.split('va=')[1]; var url = 'http://boss.yahooapis.com/ysearch/web/v1/' + searchterm + '?format=json&' + 'callback=founddonkeys' + '&appid=' + APIkey var s = document.createElement('script'); s.setAttribute('type','text/javascript'); s.setAttribute('src',url); document.getElementsByTagName('head')[0].appendChild(s); return false; } }</script>

Page 57: Finding things on the web with BOSS

*click*

Page 58: Finding things on the web with BOSS

Using the YUI library (YUI3 JavaScript and CSS grids) you

can easily make this much cooler:

Page 59: Finding things on the web with BOSS
Page 60: Finding things on the web with BOSS
Page 61: Finding things on the web with BOSS

To make using BOSS with JavaScript easier, I’ve written

a BOSS wrapper called YBOSS:

http://icant.co.uk/sandbox/yboss/

Page 62: Finding things on the web with BOSS

<div id="results"></div><script type="text/javascript" src="yboss-lib.js"></script><script type="text/javascript">YBOSS.get({ searches:'search,news', query:'obama', count:10, callback:seedpics});function seedpics(o){ var all = '<h4>Web Sites</h4>' + o.webHTML + '<h4>News</h4>' + o.newsHTML; var out = document.getElementById('results'); out.innerHTML = all;}</script>

Page 64: Finding things on the web with BOSS

There’s also the Python mashup framework that

allows for SQL for remixing arbitrary XML/JSON sources:

http://developer.yahoo.com/search/boss/mashup.html

Page 66: Finding things on the web with BOSS

All this has been around for a while.

Page 67: Finding things on the web with BOSS

Here are some new things added lately:

Page 68: Finding things on the web with BOSS

People are trying to make the web a less messier place by

adding semantic data to HTML documents.

Page 69: Finding things on the web with BOSS

Using SearchMonkey technology BOSS now lists this information in the results.

http://www.flickr.com/photos/glenscott/3273401181/

Page 71: Finding things on the web with BOSS

Using the view=keyterms parameter you can get

keywords associated with each result.

Page 72: Finding things on the web with BOSS

http://keywordfinder.org

Page 73: Finding things on the web with BOSS

In order to get longer descriptions of each result

you can now use the abstract=long parameter to

get up to 300 characters instead of 130.

Page 74: Finding things on the web with BOSS

Another thing we’ve done is using the Yahoo Site Explorer

and bundle it with BOSS.

Page 75: Finding things on the web with BOSS

This way you can now get page information and page inlink information with two

new BOSS services.

Page 78: Finding things on the web with BOSS

So what has been done using BOSS?

Page 79: Finding things on the web with BOSS

http://ask-boss.appspot.com/

Page 80: Finding things on the web with BOSS

http://ask-boss.appspot.com/

Page 81: Finding things on the web with BOSS

http://ask-boss.appspot.com/

Page 82: Finding things on the web with BOSS

http://hakia.com/

Page 83: Finding things on the web with BOSS

http://www.oneriot.com/

Page 84: Finding things on the web with BOSS

And on a more lighter note:

Page 85: Finding things on the web with BOSS

The client side is where strange things happen.

http://isithackday.com/hacks/web-the-adventure/

Page 86: Finding things on the web with BOSS

The motherlode of BOSS implementations:

http://mashable.com/boss/

http://delicious.com/tag/bossmashup

Add yours by tagging it with “bossmashup” on Del.icio.us!

Page 87: Finding things on the web with BOSS

Keep in touch:

Christian Heilmann

http://wait-till-i.com

http://scriptingenabled.org

http://twitter.com/codepo8

T H A N K S !