I’ve read and enjoyed your articles on adding Twitter / Google search boxes to a website. I am trying to figure out a way to have one search box on my site that displays results (in a multi-column horizontal table) for multiple sources, particularly Twitter / Google / YouTube. Any help would be appreciated. Thanks!
Cool idea, but I’m afraid that you’re probably going to be stuck having to do some programming to get this to work. The problem is that generally all the search engines on different sites, whether it’s Google or Amazon, eBay or Yelp, are built on the assumption that you hand the query string to their application and in addition to producing the search results, it also produces everything else required for the page to be a full and proper Web page.
Even if you could embed an eBay search result, say, on your page, the embedded page would think it’s a full page unto itself and would layout weirdly.
Having said that, though, there are ways we can explore to try and solve pieces of what you seek. For example, Google has a very slick custom search capability that allows you to embed search results in your own results page. It can’t include search results from other pages, but it’s an interesting starting point.
You could also explore using an IFRAME, an HTML entity that essentially lets you embed an entire Web page as a component of a larger page. Let’s dabble in that for a minute…
The trick is that you need to actually have multiple Web pages because the iframe creates a space within which another Web page is going to live. A simple version would be to actually include the Google home page within the iframe, for example, which looks like this HTML-code-wise:
If I drop this as active code onto this page, here’s what you’ll see:
Try it. It really works.
The problem, as you can see, is that Google doesn’t design its search page or search results page to be embedded into another page, so it’s a poor fit and confusing. Ya gotta do a lot of scrolling!
You can still embed a search box into a page and hand the results to a search engine, knowing that while the presentation of the box is nice, the results are going to be a bit, um, squished. That’d be done by creating a stark, simple HTML page that just contains the element you are going to embed in the iframe, then letting your users fend for themselves once the search is completed.
To integrate search results from multiple sites you really need to write some code, because you’re going to need your program to execute the search and parse the results from multiple sites, then somehow integrate those results into a unified presentation (perhaps by column, as you suggest, in which case you could have each column as its own iframe, but then you can’t push simultaneous results out easily and you still have the problem of search results layout within an iframe).
Having written multi-site search results parsing programs in the past, I’ll also warn you that it’s pretty tricky because a lot of sites are constantly tweaking their pages and page layout, things that you don’t realize as a user but will very quickly recognize when your parsing routines keep breaking.
So, in the end, no great answer. No magic solution. You can have a workaround that kind of accomplishes what you seek, but to do what you want, you’re going to have a tricky hill to climb.