Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


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.


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  




Categorized: HTML, JavaScript and Web Site Programming   (Article 9863, Written by )
Tagged: amazon, ebay, google, html, parsing web pages, search engines, yelp
Previous: Review: ZAGG iPad 2 ZAGGskin
Next: Apply an Amazon Gift Code / Card / Certificate to my Amazon account?




Reader Comments To Date:

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, Dave, for all your helpful information 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!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 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. Further, 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. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.