3

Since Google started giving a very nice cinema listings layout, I would like to make an android app that the user could take the information from this page and display it for the area they input.

I'm not asking how to make the app, but using Java how would I go about dynamically taking the information from this webpage? Could I parse it as XML? It seems a little tricky this way.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Mark D
  • 1,309
  • 4
  • 19
  • 38
  • 1
    There appears to be an easier way: http://www.google.com/ig/api?movies=15122 see http://stackoverflow.com/questions/439857/is-there-a-movie-showtime-api – Earlz Dec 27 '10 at 00:47
  • 1
    Scraping data off of Web pages is one solution, but one that involves a fair amount of pain and suffering, particularly as they change the page layout over time. Definitely find some API, such as the YQL example shown in one of the answers. – CommonsWare Dec 27 '10 at 01:01

2 Answers2

1

Taking you question 'title' literally, see my answer to this question for how to grab the raw html using a web url... Android Dev: How do I extract data from the web and use the data in my app?

I do this and use a 3rd-party class called HtmlCleaner which returns XML which can be searched using XPATH.

As has been said, however, there may well be better ways to do what you want and the comment from CommonsWare in particular is all too true. It's painful and the slightest change in the html can throw your parsing code off completely and require you to re-write things.

Community
  • 1
  • 1
Squonk
  • 48,735
  • 19
  • 103
  • 135
0

I did a quick Google Search and couldn't find a Google API for the cinema listings, although you could see if they expose these in the Google Base API.

One alternative would be using the Yahoo Query Language API. They do have a showtimes API that you can query in Java. Here is the YQL syntax you'd use:

select * from movies.showtimes

To get a list of all movies. Then:

select * from movies.showtimes where location='myzip' and name='one of the movies'

You could also do

select * from movies.showtimes where location='myzip' and name in whatever

You can use the console to discover what this API has to offer here: http://developer.yahoo.com/yql/console/?env=http://datatables.org/alltables.env#h=desc%20movies.showtimes

As far as implementation, I'm not a Java dev (mainly LAMP and .NET) so I can't give you code samples, but the YQL API is a RESTful API, therefore you just have to hit the API with the correct parameters in the request and it will return the XML results.

Hopefully this will help you find what you're looking for!

Jesse Bunch
  • 6,651
  • 4
  • 36
  • 59