wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Relative URLs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Relative URLs" Watch "Relative URLs" New topic
Author

Relative URLs

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
How my java code will get the all relative URLs e.g.
www.yahoo.com/aa
www.yahoo.com/bb
www.yahoo.com/cc
www.yahoo.com/dd
www.yahoo.com/ee
etc.

Thanks & best regards
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

If all those URLs are located in an HTML page you can parse the page and look for all HREF and SRC attributes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
What do you mean by "relative URLs"? URLs are always absolute; paths within a web site may be relative.

Can you give an example of an input and an output of what you're trying to do?


Ping & DNS - my free Android networking tools app
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Originally posted by Ulf Dittmer:
What do you mean by "relative URLs"? URLs are always absolute; paths within a web site may be relative.

Can you give an example of an input and an output of what you're trying to do?


http://www.javaranch.com has many other related URLs e.g.
http://www.coderanch.com/forums/user/edit
http://www.coderanch.com/forums/user/login
http://faq.javaranch.com/Watch/
http://www.javaranch.com
etc.

How can my java code read the related URLs of http://www.javaranch.com

Thanks again & best regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
So the input would be a web page, and the output would be a list of all URLs on that web page?
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Originally posted by Ulf Dittmer:
So the input would be a web page, and the output would be a list of all URLs on that web page?


yes but how could I achieve this

Thanks again
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Like I said, parse the page and filter out the right attributes.



Of course SRC is not the only one. The following could also be used:
ACTION (forms)
BACKGROUND
CODEBASE
SRC (images, iframes, etc)

Plus possibly others.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ulf Dittmer:
So the input would be a web page, and the output would be a list of all URLs on that web page?


Mhhh, my initial understanding was that the input would be a website address, and the output would be the URLs of all pages that belong to that site.

To which the answer would have been: not possible in general, not with Java or any other language. The HTTP-protocoll simply doesn't provide the necessary information.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Originally posted by Rob Prime:
Like I said, parse the page and filter out the right attributes.



Of course SRC is not the only one. The following could also be used:
ACTION (forms)
BACKGROUND
CODEBASE
SRC (images, iframes, etc)

Plus possibly others.


great!

Thanks a lot. I am trying to understand

Thanks & best regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Relative URLs