Free tech support / small logo


How can I embed search results on my own page?

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!


Dave's Answer:

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:

<iframe src="http://www.google.com/" width="530" height="250"></iframe>

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.


Also check out:








Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
Comments · Add Comment
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!
Rather amazingly, there are no comments on this article yet.

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Recent Entries


Search
I Need Help!
Need Help? Ask Dave Taylor!


© 2002 - 2012 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.