how can i get links in a web page without loading it? (basically what i want is this. a user enters a URL and i want to load all the available links inside that URL.) can you please tell me a way to achieve this
A:
You'll have to load the page on your server and then find the links, preferably by loading up the document in an HTML/XML parser and traversing that DOM. The server could then send the links back to the client.
You can't do it on the client because the browser won't let your Javascript code look at the contents of the page from a different domain.
Pointy
2010-10-06 15:47:20
can you please give me code example or any link to a resource where i can study a bit about it
netha
2010-10-06 16:09:20
It completely depends on what sort of server-side environment you've got. There are many, many possibilities.
Pointy
2010-10-06 16:50:52
A:
If you want the content of a page you'll have to load it. But what you can do is loading it in memory and parse it to get all the <a>
tags and their content.
You'll be able to parse this XML with tools like JDom or Sax if you're working with java (as your tag says) or with simple DOM tools with javascript.
Resources :
On the same topic :
- get all the href attributes of a web site (javascript)
Colin Hebert
2010-10-06 15:47:20
@Paddy, you're right, and in this case the best thing to do is looking right to the `<a` tags manually.
Colin Hebert
2010-10-06 15:52:43