Querying the time using Google Search Results - android

This one is puzzling me...
For my Android application I want to be able to return the current time in any location the user requests (right down to city level). The request itself comes from a voice command, so I cannot use alternative methods.
The most obvious way (so I thought) was to query Google, but I need your brains to help me solve how to extract the data I want please!
In Google, query:
"What's the time in China"
You should see a 'widget' at the top displaying the answer nicely. View the page source and search on 'China' and it's there - I thought great, this is going to be easy!
But...
"What's the time in London"
Although the display in Google appears the same, there is no result for 'London' when searching the source HTML...?
Using Google Chrome, I inspect the element of the 'widget' and can then view the contents I wish to extract in all cases.
So, my questions is firstly, am I missing something obvious (Google don't want us to be able to do this for example)? Or is there a way to 'force' the result to be in the HTML by structuring the query perhaps?
Secondly, is there a way to access the specific 'element container' and return the results to my Android Application?
I thank you in advance...

You should really use an API instead of parsing html.
I guess there are many many API which will give you the time in a given city.
http://www.worldweatheronline.com/time-zone-api.aspx for example (havnt tried it myself)
If you still want to extract data from the google result (which is html), check for html parsers like in this post : Parse HTML in Android

Related

Android - find image link API

Hey !
I have an Android app where the user can search on a specific subject, let's take the word "Cats" for example. When the user submits the search I want to find an image similar or on the subjects the searched for. A search engine for images more or less. I want something "easy" to deal with, so I thought about integrating the Google Search API into my app. Let the user search Google, and take the first image that comes up.
However, I haven't found any example and I just need a push in the right direction. If you could give me an example API for my needs, that'd be great.
Apparently the Google Search API never was fully deprecated it's still up and running. It provides JSON data and is easily parsed with Android.
If anyone else needs an image API here's a test search: https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=searchquery&rsz=8&start=1&imgsz=small|medium
And the JSON reference: https://developers.google.com/image-search/v1/jsondevguide

Want my app to export data into html file

It's late and my brain can't even think of the proper things to search for to find the help I need.
Here's what I'm aiming for:
My app takes in a bunch of data from the user. Specifically sizes for windows and doors around a house. My app takes all that data and determines how much material is required, etc.
Here's where I'm stuck:
What I'd like to do is turn that all into a fancy looking report and offer the user the ability to print it. I figured the easiest way to do that would be to generate a report using HTML (or PDF) and have it open up in a web browser, which already has print capabilities.
Can anyone tell me if this seems like a good strategy for what I'm trying accomplish? And if so, point me in the right direction (or to the exact same questions that's already been answered somewhere on this forum).
Thanks.

How to make an app submit info into a webform

I was trying to write an android app to help people do easier searches on multiple websites like craiglist, ebay ..etc
I am not sure where really to start from, or the name of the technology I would be using. To make it more accurate question, these websites are all forms based that you either post stuffs or retreive stuffs through searching. How can I make my android app actually in which it will ask the user for a item name (that part I know) and then send item name to say craiglist so it gets the results back?
I was thinking of copying the url that is displayed on my broswer when I click search on any of the website and using the same link with string manipulation to include whats needed.
Is this correct? Any other ideas are I know? I am kinda all over the place, but I need a starting point.
Some sites might expose a public API for you to connect with, but that's site specific.
Sites that do not expose such a system can be "scraped", which means you're using string manipulation (as you mentioned) to parse our the data you're after.
Both ways require basic knowledge on how to perform HTTP operations, there are several ways to do this but the easiest way it to use the HttpURLConnection class as described in various tutorials on the web.
Googling for "android http GET POST tutorial" should point you in the right way to get started with your adventure :)

Getting google search result for android application

I googled this for quiet a bit tonight and haven't really came across a good solution.
I simply needed to run a query on google and retrieve the top, say 10 results. Right now the only information I need is the URL of the top 10 results. It seems like Google puts a lot of limitations if you want the results returned as in xml, unless you're a paid customer. So what's my best option here? Simply GET the html of the "http://google.com/search?q=" and try to parse it out manually? Is there a better method of doing so?

How to implement a search like the google maps address search?

I would like to create a search in my app which acts like the map search in the Google Maps app.
I have creates an an auto complete text view which updates dynamically based on the results of the Geocoder.GetLocationByName() Method.
However the results retrieved from this function are really bad and not at all consistent with the text I pass to it.
Is there a better method of doing this to achieve accurate results?
So it's not the geosearch that's your problem, but the autocompletion, right? Well I assume you need the whole set of possible values in order to obtain a decent auto-completion. Another way would be to take apart the google javascript code that performs the auto-completion and talk to their servers, pretending you're typing into one of "their" fields. However, this isn't only probably against their terms of service but also a bit shaky because they might a) detect and prevent this or b) change their interface in the future.
Your best guess would be to get a list of all cities, streets, etc in question.
hopefully this should be able to do the trick :=)
https://developers.google.com/places/documentation/autocomplete
good luck (testing it myself right now)

Categories

Resources