Solved

is it possible to query imdb.com from my website using a jsp page

Posted on 2007-04-11
11
584 Views
Last Modified: 2008-01-09
I wanted to write a JSP page for my website that would allow a user to enter a movie name and then query IMDB.com and display the page with the info on that movie.  Is this possible, and if so how would I do it?

thanks!
0
Comment
Question by:urobins
  • 6
  • 5
11 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 18892605
Here is a start.
<%@ page import="java.net.*,java.io.*" %>
<%
        String movieTitle = request.getParameter("movieTitle");
        if(movieTitle == null)movieTitle = "Casablanca";
        String movieTitleEncoded = URLEncoder.encode(movieTitle, "UTF-8");
        URL url = new URL("http://imdb.com/find?s=all&q=" + movieTitleEncoded);
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
           // parse the parts you want to display
            out.print(line);
        }
        rd.close();
%>
0
 

Author Comment

by:urobins
ID: 18892654
sorry I am new to JSP I would like to just display the whole page in return, how would I do that?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18892990
Use the following page to call the page I posted in my first post.
<html>
<head>
<title>Movie Info</title>
</head>
<body>
<form action="getMovieInfo.jsp">
Please enter movie title:<input type="text" size="25" name="movieTitle"/>
<input type="submit" value="Get movie info"/>
</form>
</body>
</html>

But if you want the whole page you don't even need JSP. You could use the following in a frame on one of your HTML pages.  
<html>
<head>
<title>Movie Info</title>
<script>
function GetInfo(){
  window.location = "http://imdb.com/find?s=all&q="
                   + encodeURIComponent(document.movieForm.movieTitle.value);
}
</script>
</head>
<body>
<form name="movieForm">
Please enter movie title:<input type="text" size="25" name="movieTitle"/>
<input type="button" value="Get movie info" onclick="GetInfo();"/>
</form>
</body>
</html>
0
 

Author Comment

by:urobins
ID: 18893010
Thanks let me try this  I appreciate the help.  Now you say I can parse just certain parts, but I would need to know what they were called on IMDB Right?  I am just confused at how to pull info from a site I don't manage.  I have looked for some tutorials  but haven't found a whole lost using JSP and my book isn't all that great either.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893086
Which book are you using ?
There is a lot of info online. Google is your friend.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:urobins
ID: 18893103
How do I get it so I can use the Hyperlinks on the returned page?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893108
>Now you say I can parse just certain parts  
But, I didn't say it would be easy.  Depends on what you want to do.
0
 

Author Comment

by:urobins
ID: 18893123
I bought Beginning Java EE5.  I found a lot of JSP info online but a lot of it is over my head, or too basic "hello world" world examples.  Thanks again.  I can get it to return the IMDB page but I have the problem where a movie title will return multiple matches and I can't select them...
0
 

Author Comment

by:urobins
ID: 18893129
>But, I didn't say it would be easy.  Depends on what you want to do

Oh :)  thats probly much greater than where I am at huh :)

thanks for all of your help.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893239
I haven't read that book. But I recommend you read  
http://java.sun.com/javaee/5/docs/tutorial/doc/
0
 

Author Comment

by:urobins
ID: 18893305
Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now