aspose file tools
The moose likes Beginning Java and the fly likes HOw to find URL or Href link in the PAge? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "HOw to find URL or Href link in the PAge?" Watch "HOw to find URL or Href link in the PAge?" New topic
Author

HOw to find URL or Href link in the PAge?

johny bent
Greenhorn

Joined: Oct 24, 2009
Posts: 3
I already do the code for requesting the page from any URL entered..BUt the Problem is I wanna find the URL or Href link in the page that i already requested...Can anybody help me?...

This is the code..



I try to play with in.readLine but still cannot get it?....Anyone pleaseeee...


Java Kid
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

"henkrex krex", please check your private messages for an important administrative matter.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
johny bent
Greenhorn

Joined: Oct 24, 2009
Posts: 3
Bear Bibeault wrote:"henkrex krex", please check your private messages for an important administrative matter.



Sorry for that ....I already change to my real name..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32689
    
    4
Welcome to the Ranch

Thank you for correcting the name problem.

Please maintain code indentation and formatting with the CODE button; since you are new, I have edited your post and you can see how much better it looks. Please tell us the details and exactly what goes wrong.

Don't know, but can you find a regular expression which matches a URL?
johny bent
Greenhorn

Joined: Oct 24, 2009
Posts: 3
Tq for the correction....Nothing problem with this code...But what i asked is how to find and get the href link in the page that i requested form http://localhost/mmpp...
System.out.println(inputLine); will give you the page requested and after that I need the function to find and get the href link in that page....Hope you can understand...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16692
    
  19

johny bent wrote:System.out.println(inputLine); will give you the page requested and after that I need the function to find and get the href link in that page....Hope you can understand...


Well, how much parsing have you done? It pretty straightforward, you need to scan the string for the portion of the string that you want. This can be done by simply looping through the chars of the string, or you can use one of the higher level searching methods of the string class, or use regexes. See the java.lang.String and java.util.regex.Pattern class for more info.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: HOw to find URL or Href link in the PAge?
 
Similar Threads
EOF on System.in
java.io.IOException: Premature EOF
Simple program for URL
Connection in servlets
How to read text content not source code from webpage in java ?