X
Innovation

The astounding $14million Ethernet extender

I was helping a friend find a good price on a powerline Ethernet extender like the one I bought a few months ago, and stumbled upon this bargain:Luckily I found one cheaper here:When I showed this to my friend his first comment was "For 1/5 of a mil you'd think they'd include shipping". True, but at least there was no tax.
Written by Ed Burnette, Contributor

I was helping a friend find a good price on a powerline Ethernet extender like the one I bought a few months ago, and stumbled upon this bargain:

14mil.png

Luckily I found one cheaper here:

bestprice.png

When I showed this to my friend his first comment was "For 1/5 of a mil you'd think they'd include shipping". True, but at least there was no tax.

I don't have any inside knowledge on how the shopping site gets its prices, but I suspect they're using a method called "screen scraping". In this method you just fetch every product web page and try to parse out the HTML to find where the number you want is located. This is fairly straightforward but it doesn't always work, especially if the site you're scraping changes its format. Also some sites don't appreciate being used in this manner.

A better solution is to use a web service. Web services are sort of like web pages in that you access them with an "http://something" address. But instead of returning an HTML page they return the answer in a form that is easier for a computer program to understand, like XML or JSON. If the site you're querying provides a web service then you can write a program (like a price comparison server) that calls the service and gets the result.

Here's an example of a web service. When you click on this link, you will actually be calling a service from Google that translates the text "thank you" from one language to another, in this case English to French. Go ahead and click it; there's no code that runs in your browser or anything dangerous. Here's what I get:

{"responseData": {"translatedText":"merci"},
 "responseDetails": null, "responseStatus": 200}
The answer comes back in a JSON format that can easily be loaded by Javascript, Java, or any other language. When web services first started out, most of them used a protocol called SOAP that wrapped both the request and the response in a standard XML "envelope". This was very general, but also very cumbersome. Nowadays, many web services are "REST-ful", meaning the query is encoded in a regular HTTP request (like the one in that link) and the results come back in a simple format.

You can see an example of code that uses web services in the downloadable examples from my upcoming book, Hello, Android. I wrote a program that prompts for some text, calls the service to translate it to another language, and then translates it back into your original language to see how it comes out. The examples are free; from the home page select the Code link, download the zip file, and open up the Translate project.

For more info on the Google Language API used in the example, including the terms of use, see their site.

[ Read: More programming tips on Dev Connection ]

Editorial standards