|  | |  |
07-05-2008, 12:09 AM
|
#16 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| It is not that my code is not working. It's showing the output perfectly what i have wrote the code which is the source code of a search result page or a web page. From here i want to manipulate the out put in which i can get result number which is "923,000,000" for yahoo that i have mentioned url in program that i have given. I am stuck here and don't know how to manipulate the output in order to get that number and store in a variable. I have nothing to do with the rest of the output, i just want the number only in the output.
any sample lines.......!!!!
Last edited by @script; 07-05-2008 at 12:13 AM.
Reason: smoe more info addition
|
| |
07-05-2008, 06:15 AM
|
#17 (permalink)
| | Newbie
Join Date: Jun 2002 Location: Denmark
Posts: 1,726
| So you're looking for a way to convert teh string "93.200.000" into an int with the value 93.200.000 ?
That's just about the easiest thing to do: Code: int i = Integer.valueOf(urlResult).intValue(); |
| |
07-06-2008, 10:42 PM
|
#18 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| no!!!!! I know how to convert the string to number. This is not my question. I want that number to be stored in a variable using program. And one more thing that as i said i want to manipulate the output.
any code suggestions form u people!!!!!!!!!!!!!!!!!!!!!!!! |
| |
07-07-2008, 03:02 PM
|
#19 (permalink)
| | Java fanboy
Join Date: Aug 2003
Posts: 1,175
| Quote: |
I want that number to be stored in a variable using program
| Redhead told you exactly that - how to store the number in a variable. By your belligerence, I assume "variable" is probably not the word you want to use. If you want help, you need to comunicate clearly what it is you are trying to do.
And replacing "you" with "u" and adding a bunch of "!!!!!!!!" to the end of sentences does not help with clarity. |
| |
07-07-2008, 10:00 PM
|
#20 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| oh come on. I can understand what Redhead is talking, but it is not what i want. I want the number from output from the program. |
| |
07-08-2008, 09:41 AM
|
#21 (permalink)
| | Newbie
Join Date: Jun 2002 Location: Denmark
Posts: 1,726
| So you want to make an external program call with the value 93.200.000 as an argument to the program ?? Code: Process p = Runtime.getRuntime().exec("myprogram" + " " + i); Or you want the execution of your java program to return with the number |
| |
07-09-2008, 05:44 AM
|
#22 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| Ok, Let's put it straight.
In the output of the code you will some where find the code as"<font size=-1>Results <b>1</b> - <b>10</b> of about <b>483,000,000</b> for <b>java </b>". can you give me the code to get that number. Note:Provided we don't know that number. We have to get that number using the program only. That number may change from time to time that's why. I want the code to do that coz i don't know how to get that one. |
| |
07-09-2008, 07:37 PM
|
#23 (permalink)
| | Java fanboy
Join Date: Aug 2003
Posts: 1,175
| Why not simply search for the third "<b>" and parse everything between it and "</b>"? |
| |
07-09-2008, 09:55 PM
|
#24 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| Ok, no problem. Code to get it please! |
| |
07-10-2008, 03:51 AM
|
#25 (permalink)
| | Java fanboy
Join Date: Aug 2003
Posts: 1,175
| It won't be pretty, but the most straight-forward solution is to just use "indexOf" and "substring" - all you'll need are a few lines. Just find the first two "</b>" and cut everything (including them) out, and you're left with Code: of about <b>483,000,000</b> for <b>java </b> Find the index of "<b>" and "</b>", use the values in substring (adding offsets as necessary), and you're left with "483,000,000".
Being that all you're using are two String methods, it should be a peice of cake for you to code up. |
| |
07-14-2008, 03:23 AM
|
#26 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| can you give me the example? |
| |
07-14-2008, 03:53 AM
|
#27 (permalink)
| | Java fanboy
Join Date: Aug 2003
Posts: 1,175
| Seriously, this is a task even a first-year computer science student can accomplish. I even pointed out what methods you should use. We don't mind helping people out with a problem, but asking us to code up everything for you is taking advantage of our generosity.
You should be able to do this bit on your own or you probably shouldn't be coding in the first place. |
| |
07-14-2008, 04:42 AM
|
#28 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| Ooooops!
actually i might have posted the following thing instead i posted that one. i got the code as follows:
i=line.indexOf("<b>",4);
System.out.println(i);
x=line.indexOf("</b>",4);
System.out.println(x);
in the out put it is showing as: i'm showing last few lines of output,
al for the Yahoo! Search user and does not include all McAfee SiteAdvisor red ra
tings.<\/p>"},"ssstate":"scan"});});</script></body></html><!-- m226.search.ac2.
yahoo.com uncompressed/chunked Mon Jul 14 04:30:07 PDT 2008 -->
3205
-1
first one is for <b> and -1 is showed for </b> which means for </b> it is unable to find the index.
may i know what's wrong with that code sir......
thanks...  |
| |
07-14-2008, 05:43 PM
|
#29 (permalink)
| | Java fanboy
Join Date: Aug 2003
Posts: 1,175
| Unless the output from Yahoo changed since you wrote that program, you're looking for the wrong stuff. Just before the search total, there's a span called "infotext" that appears to be unique. Use that to cut off the beginng text. Then you should be able to simply whittle it down from there. |
| |
07-21-2008, 07:20 PM
|
#30 (permalink)
| | Code Monkey
Join Date: May 2008
Posts: 36
| GOT IT!  |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -8. The time now is 01:31 AM. |
Copyright © 2000-2008, Milano Interactive Web Hosting provided by Portal 360 Web Hosting |  | |