Solved

Querying a web site for Single Info by Java

Posted on 2004-04-26
10
207 Views
Last Modified: 2010-03-31

Dear Experts

My question is , can I query a web site for specific info - and only this info - by Java ?

for example, there is a web site that give the weather forecast for cities & countries, and from my application ( actually a j2me device )  I want to query for spicific city and get only this value ( not in HTML ), I did something like :

URL = "www.webforecast.com/?country=USA&city=california&weather=night&day=12/04/2004"

but it gave me the whole page  in HTML format,

what I need is only for example : 24 celcuis

thanks for your help

0
Comment
Question by:kotoz23
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
the site would need to support what u require.
otherwise u need to parese the html.
0
 

Expert Comment

by:pinju
Comment Utility
As objects said, it can be done only if the site supports retrieval of data based upon ur request.

Alos if it does....It will always give u a html page.......so u have to parse it accodingly to get the desired data which then you can show in ur application
0
 

Author Comment

by:kotoz23
Comment Utility

So it seems that I've to make a web site that take this information first from that site and then forward it to the j2me device ?, is it possible ? ( please give me some hints because I am not a web server developer )

So what is the use of the .setRequestProperty("content-type","plain/text")  instead of plain/html ?!

thanks for your help
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>
So it seems that I've to make a web site that take this information first from that site and then forward it to the j2me device ?, is it possible ?
>>

Yes. This would be using a proxy essentially. The proxy would take the parameter from the mobile device, forward that to the real site, get the response, scrapes the required info from the page and then returns that subset of info to the mobile device. You will need control of a scriptable web server in order to do this
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
first you should check that the site doesn't already provide a service you can use.

> and then forward it to the j2me device ?, is it possible ?

Figuratively speaking no.
What your j2me device would do is make a request to your server, which would then return the required results.
These could be obtained by calling the target site and extracting thje required details from the page, or in this case they could be just returned from memory so you're not pulling the same details from target site on every request.

> So what is the use of the .setRequestProperty("content-type","plain/text")  instead of plain/html ?!

That says that the returned response is plain text and not html.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:kotoz23
Comment Utility

Thank you all, but if ".setRequestProperty("content-type","plain/text")  " says that I get the response in text, so no need to do this proxy, because the information I'll get will be small anyway, no pictures, no tags.. , Am I right ?

I actually tried setRequestProperty("content-type","plain/text")  but it gave me same as HTML ?!!

maybe I used it wrong ?

please help

0
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
Comment Utility
sorry read your last q too fast, content-type is typically set on the *response* from the server, and not the request.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 50 total points
Comment Utility
You certainly can't use it to force the server to return its results in a different format
0
 

Author Comment

by:kotoz23
Comment Utility

Object : can you give some hint in this question http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20927019.html

thanks
0
 

Author Comment

by:kotoz23
Comment Utility

just an advice, what is the best to use for such proxy job , php, cgi/c++, javascript, servlet ?

or all possible ?

thanks, if required another question I'll do
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

771 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

10 Experts available now in Live!

Get 1:1 Help Now