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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 61209
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 38851
    
  23
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: 18837
    
  40

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://aspose.com/file-tools
 
subject: HOw to find URL or Href link in the PAge?