Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Java

Reply
 
LinkBack Thread Tools Display Modes
Old 07-05-2008, 12:09 AM   #16 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
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
@script is offline   Reply With Quote
Old 07-05-2008, 06:15 AM   #17 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
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();
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-06-2008, 10:42 PM   #18 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
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!!!!!!!!!!!!!!!!!!!!!!!!
@script is offline   Reply With Quote
Old 07-07-2008, 03:02 PM   #19 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
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.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-07-2008, 10:00 PM   #20 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
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.
@script is offline   Reply With Quote
Old 07-08-2008, 09:41 AM   #21 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
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
Code:
 return i;
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-09-2008, 05:44 AM   #22 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
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.
@script is offline   Reply With Quote
Old 07-09-2008, 07:37 PM   #23 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
Why not simply search for the third "<b>" and parse everything between it and "</b>"?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-09-2008, 09:55 PM   #24 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
Ok, no problem. Code to get it please!
@script is offline   Reply With Quote
Old 07-10-2008, 03:51 AM   #25 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
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.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-14-2008, 03:23 AM   #26 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
can you give me the example?
@script is offline   Reply With Quote
Old 07-14-2008, 03:53 AM   #27 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
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.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-14-2008, 04:42 AM   #28 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
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...
@script is offline   Reply With Quote
Old 07-14-2008, 05:43 PM   #29 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
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.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-21-2008, 07:20 PM   #30 (permalink)
@script
Code Monkey
 
Join Date: May 2008
Posts: 36
@script is on a distinguished road
GOT IT!
@script is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search engine seanu92 Lounge 3 07-09-2007 01:09 PM
basic search engine with PHP trevor PHP 3 02-24-2007 08:43 AM
Make a search engine for your website with PHP zhisede PHP 3 10-25-2005 08:54 AM
Search Engine Submittions Eyelfixit Lounge 12 07-25-2003 09:09 PM
Please Review ZapMeta - New Search Engine khn Program Design and Methods 3 07-06-2003 10:15 AM


All times are GMT -8. The time now is 01:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting