Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HOw to find URL or Href link in the PAge?

 
johny bent
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"henkrex krex", please check your private messages for an important administrative matter.
 
johny bent
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21114
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic