Solved

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

Posted on 2007-04-11
11
594 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
Part Two of the two-part Q&A series with MalwareTech.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

630 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