Web Page Interaction Question

Reply

Join Date: Dec 2008
Posts: 10
Reputation: sheff21 is an unknown quantity at this point 
Solved Threads: 0
sheff21 sheff21 is offline Offline
Newbie Poster

Web Page Interaction Question

 
0
  #1
Dec 26th, 2008
My friend and I are working on a school project and our hope was to have a Java program take a zip code from the user and then connect to weather.com (or any other web site) and look up the local weather. I assume this is possible but I cannot quite figure it out. I am able to get the source code from a site by using the instream, however, it is difficult to find the information I need in the source code. Is there any way to access the page and retrieve the actual text from the site. Thanks!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,566
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 196
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: Web Page Interaction Question

 
0
  #2
Dec 26th, 2008
Have you managed to send the site a request to look up the weather (based on the zip you send it) yet? If not, plain text isn't going to do you any good. So let us know which part you are stuck at.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 10
Reputation: sheff21 is an unknown quantity at this point 
Solved Threads: 0
sheff21 sheff21 is offline Offline
Newbie Poster

Re: Web Page Interaction Question

 
0
  #3
Dec 26th, 2008
Well I don't know how to send a request. I just hard coded it by copying the URL from the site after performing a search and then replaced all the places they used the zip in their URL with a variable that contained it. So, I guess I'm stuck at both parts, sending a request as well as retrieving the info.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: Web Page Interaction Question

 
0
  #4
Dec 27th, 2008
Sheff21, you need to learn first about HTTP. And how data is sent to a web page via GET or POST.

You send a request to a Web page via the GET or POST method, if you have done some basic web programming or written some forms in HTML you would have encountered them, or you could read about them in the page I have linked to HTTP.

Also once you have cleared your HTTP concepts, Here is an example on how to perform POST in Core Java.
Performing a GET is as simple as appending the the URL with a "?" and then appending the data with the format <param1>=<value1>&<param2>=<value2>& ... &<paramN>=<valueN> and invoking it.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Web Page Interaction Question

 
0
  #5
Dec 27th, 2008
Calling a URL and parsing it for plain text values is not what you would want. What you first require is an HTTP API from the site owners which will provide you with proper values. But this certainly requires an API defined at their end and would require you to spare them some usage fees if at all the API exists.
Then a typical interaction between your program and their site would be something like this: You call their URL using either HTTP GET or POST (as mentioned by stephen84s) as specified in their API specification providing them the zip code and they return you the current whether for that zip code as a response.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Web Page Interaction Question

 
0
  #6
Dec 27th, 2008
> But this certainly requires an API defined at their end

Not certainly, screen scraping is always an option and which I guess is what the OP is looking for in this case given that it's a school project.

> it is difficult to find the information I need in the source code

As long as you don't abuse the service, XQuery and some other options can make your screen scraping a bit easier.

This involves a two step process:
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC