Redirecting search results into an ASP.NET page - asp.net

I've an ASP.NET page with a textbox and a option from user of the following choices: Wikipedia, Google, Dictionary.com, Flickr, Google images.
The user enters a word(s) in the textbox and selects a choice among the following.
Depending on the choice select by the user I wish to return the following.
Wikipedia: Return the content and link to the page corresponding to the topic about the word.
Google: Return the top 10 results of google search for this word.
Flickr: Return a few images atmost 10 images from flickr search
GoogleImage: Return a few images from google image search.
Dictionary: Return the meaning of the word.
How can I do that?

Since you are wanting to do some processing on the results prior to displaying them, your best bet is probably to invoke a web request on the server to fetch your results as RSS or some other parsable XML format.
So first up, we have Wikipedia, which has API support for open search, and queries with XML or JSON output. You can get the details of the API by going to: http://en.wikipedia.org/w/api.php
I would think either the query action, or opensearch action would be what you want.
Right, now there is Google, which supports search results as RSS through their Active Search feature. The link takes you to the main page where you can build the query, at which point it should be easy to drop in your search terms. There is also the Google Search AJAX API, which you can find out about here (See the "Flash and other Non-Javascript Environments" section for building the URLs directly. I believe this option should give you access to Google Image results as well.
For Flickr, have a look at this App Garden page. There are several output formats available to choose from.
I wasn't able to find anything real solid on getting results from Dictionary.com, but it does appear that they have an API. You might be able to dig through google and find some references on how to get search results as XML or JSON. There are also several other Dictionary sites which may have more information about their APIs. While searching I managed to find this SO question about word lookup from google dictionary.
Hope this helps.

Have an iframe within your page, and then set the src of the frame to the appropriate query string that you craft from the user's input.
This can be done from javascript within the page, in response to the user selecting something in the 'choice' dropdown. You can have the appropriate urls already embedded in the javascript (as variables), and just substitute in the user's input.

Related

Google Maps query businesses Near Me Search

Objective
Client wants a map on the search results page that shows a Google Map with all business listings, matching the users search parameters, that are near that user.
Background
I have a client who is building a business directory website.
This client is currently using a WordPress plugin called GeoDirectory and would like to have a map on the search results page that shows a Google Map with all business listings, matching the users search parameters, that are near that user.
These would not be the businesses on the website they would be the businesses that you would get if you did a search on Google say "restaurants near me" and it would show those businesses.
The client wants it to look exactly like the google map that results from that search so it would take the query created by the GeoDirectory plugin and show a list of businesses from the clients site that match a specific category and also a google map of other businesses in the area that are listed on Google.
Question
Is this possible?
I don't really have a link to show an example but if you type in "restaurants near me" in the google search bar and click on the map that pops up in the search results you will see what I mean.
Is it possible?
I don't know WordPress, but coming from a Google Maps background, I can definitely tell you that yes, it is possible.
What can I use?
Depending where you make your request from, you can either use the Places API Web Service (server side) or the JavaScript API with the Places Library (for client side).
For more information about the Places API and related products you can visit https://developers.google.com/places/documentation/
How can the Places API help me?
The Places API Web Service and its library for the JavaScript API have a functionality that you can use called PlacesSearch, which is exactly what you need.
Examples and Docs
To use this functionality, lets say, using the Web API, you need to make a GET request like the following:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
Using the JavaScript API, you would send a request like this:
https://developers.google.com/maps/documentation/javascript/places#place_search_requests
With this information, you can include a map, and quickly get the information you need by having the user type in a text box.
The example below demonstrates how this concept works
https://developers.google.com/maps/documentation/javascript/examples/place-search

Adding Google's standard search (not custom) to my website

My intention is to embed Google results in my website. I don't want to customise the domain/s on which the search is performed or anything, just a 'bog standard' Google search based on search parameters I pass it.
2 questions:
How do I display google results on my website as a response to search criteria entered into a textbox I have?
Is there any legislation I need to take into account?
I know my second question sounds rather strange but I'm aware that what I'm appearing to do here is present content driven by Google as though it's my own so want to avoid breaching any copyright or 'same-origin policy' type thing.
What I've Tried/Ways I Know I Could Achieve This
Screen scraping Google's response to a simple web request with the necessary query parameters (but seems a bit excessive)
Google's custom search (but I don't want to customise anything)
I've tagged this question for some more context.
As it is mentioned here
you can use your own XML parser to customize the display for your
search users.
with an http request like this:
GET /search?q=bill+material&output=xml&client=test&site=operations
But it has a limitation on number of requests per day, 500 or 1000 I guess.
Custom Search can be configured to include the entire Web in its results:
From the Google Custom Search homepage, click New search engine.
In the Sites to Search box, enter at least one valid URL (e.g. www.google.com).
Click Create.
On the next page, under Optional next steps, click Edit.
On the Basics tab, under Search Preferences, select Search the entire web but emphasize included sites.
Click Save Changes.
In the left-hand menu, under Control Panel, click Sites.
Delete the site you entered during the initial setup process.

Google Analytics and measuring search terms to destination pages

Been using internal site search with Google Analytics and while I love the ability to see what my users are searching for, I am having a really hard time figuring out what search terms lead to which pages.
When I search on both the nextPagePath and searchKeyword dimensions while filtering on the search results page at the current path, the nextPagePath is always the search results page even when I know it shouldn't be (when tracking my own obscure searches). The same goes for using the searchDestinationPage dimension. I can't get any data that shows a jump from a search results page to another page on the site.
Here's a cleaned up example of my api query.
dimensions=ga:searchKeyword,ga:nextPagePath&metrics=ga:pageviews&filters=ga:previousPagePath=#dosearch
When I use the standard Analytics UI and look at the Destination Pages list under Content->Site Search->Destination pages, I only have 25 or so, all of which are just the variations on the base search-result page URL.
Do I need additional tracking code on my search results pages? Custom variables? A different query through the API?
I can see the tracking requests going out from both the search results and the pages selected from the results.
I found a couple of questions in the Analytics forums that ask this same question, but none of them had anything resembling a working solution.
I would bet you are not using the proper dimensions in the API
See https://developers.google.com/analytics/devguides/reporting/core/dimsmets/internalsearch
ga:searchDestinationPage is probably what you wanted when using ga:nextPagePath

Bookmarking ASP.NET search results using POST or GET?

I need a little help understanding how HTML forms work. It is my understanding that forms that use GET as their method submit name/value pairs for all fields within the form tags of said submission. However, if you take a look at the follow example from Google (and I've seen this in many other places too) and only use one of the fields on the form:
http://books.google.co.uk/advanced_book_search
Rather than being sent to a page with a name/value pair for each field of the advanced search page you are taken to a much cleaner looking URL:
http://www.google.co.uk/search?tbo=p&tbm=bks&q=hitchiker&num=10
Despite all of the input fields on the advanced search page.
Onto my problem... My own advanced search page is quite large and at the moment is being POSTed to my search results page which is taking in the values and searching accordingly, no problems! However, I want my users to be able to bookmark/share their searches and in order to do this I need to have items being passed into the querystring but I don't want massive querystrings if I don't need them. If my user has only searched by a color for example then I want the URL to be something like search.aspx?color=red; If they're searching by color and size then search.aspx?color=red&size=large and so on. Is this possible?
To complicate things even further I'm using ASP.NET so it's not the easiest of things to create a form that uses GET though I do believe I have already found away around this.
If you can give any advice or a nudge in the right direction, then thank-you! :)
What you're suggesting should be easily possible if you conditionally check the querystring on the results page to ensure the key/value is there.
if(Request.QueryString["color"] != "")
{
// Add color to the seach parameters
}
To create the GET request I would think you would need to POST back to your search form and redirect to the results form from there, dynamically adding key/values to the querystring as and when they are required. This Post/Redirect/Get design pattern is typically used with web forms to help with book marking.
If you want to share bookmarked searches between users, then you'll have to share the name/value querystring options in the posted URL. It sounds like you don't want to include the pair if one wasn't specified. That's easy, just dynamically build a querystring for pairs that the user HAS provided input for. So, when processing, loop through all input controls, and if a value was provided, append it to the querystring, or not.

API for word definitions

i'm trying to implement a little app which basically only hs a label, textbox and a button and when the user enters a word, i want to connect to some online api to retrieve the word's definition and display it in the label. is this possible? all i keep finding is api's related to other stuff on google/other se's. but i have seen this in practice before so i know they are out there, i just don't know where.
I suggest you try WordNet. It has got an API that you can use over the web.
Check it out here: http://wordnet.princeton.edu/wordnet/related-projects/#web
If you search more probably you will find, but let me give you a hint:
You can make a http web request to any website who handles word definitions. You can even search for "define: " + word in google and get the response.

Resources